$value ) { $this->$key = $value; } $itid = $this->insert (); } return $itid; } function getInvoiceTrainStatistics($itid=0) { $itidCondition=' and trainId=NULL '; if (!empty($itid)) $itidCondition=' and trainId in ('.$itid.') '; $sql = 'select sum(invoicePrice) as invoicePrice ,trainId from CLD_invoice where status=2 and printStatus=1 and (untreadStatus =0 or untreadStatus=3) '.$itidCondition.' GROUP BY status'; $query = Doo::db ()->query ( $sql ); $result = $query->fetchAll (); if (! empty ( $result )) $detail = array ( 'invoicePrice' => $result [0] ['invoicePrice'] ); else $detail = array ( 'invoicePrice' => 0 ); // print_r($result); $itidCondition=' and a.trainId=NULL '; if (!empty($itid)) $itidCondition=' and a.trainId in ('.$itid.') '; $sql = 'select sum(b.receivablesPrice) as receivablesPrice ,a.trainId,count(*) as count from CLD_invoice as a left join CLD_invoiceReceivables as b on find_in_set(a.irid,b.irid) where a.status=2 and a.printStatus=1 and (a.untreadStatus =0 or a.untreadStatus=3) and a.irid!="" '.$itidCondition.' GROUP BY a.status'; $query = Doo::db ()->query ( $sql ); $result = $query->fetchAll (); if (! empty ( $result )) { $detail += array ( 'receivablesPrice' => $result [0] ['receivablesPrice'] ); $detail += array ( 'rPrice' => $detail ['invoicePrice'] - $result [0] ['receivablesPrice'] ); } else { $detail += array ( 'receivablesPrice' => 0 ); $detail += array ( 'rPrice' => $detail ['invoicePrice'] ); } return $detail; } function getInvoiceTrainingByTodo($select = "", $cid = 0,$sid=0) { Doo::loadModel ( 'staff' ); $staff = new staff (); Doo::loadModel ( 'L_category' ); $lCategory = new L_category (); $condition = array ( 'where' => "(status= 0 or status=1) and ( cid=" . $cid." or creator=".$sid." )", 'limit' => 8, 'asArray' => TRUE ); if (! empty ( $select )) $condition += array ( 'select' => $select ); $list = $this->find ( $condition ); Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); $itid = array (); foreach ( $list as $key => $value ) { $list [$key] ['trainingKey'] = $XDeode->encode ( $value ['itid'] ); $detail = $staff->getStaffBySid ( $value ['creator'] ); $list [$key] ['staff'] = $detail; $detail = $lCategory->getCategoryById ( $value ['cid'] ); $list [$key] ['category'] = $detail; array_push ( $itid, $value ['itid'] ); } // 获得开票金额合计 入账金额合计 入账完成度 Doo::loadModel ( 'invoice' ); $invoice = new invoice (); $invoiceList=$invoiceRecelvablesList=array(); if (! empty ( $itid )) { $itidSql = implode ( ',', $itid ); $invoiceList = $invoice->sumOfinvoiceTrain ( $itidSql ); $invoiceRecelvablesList = $invoice->sumOfInvoiceRecelvablesTrain ( $itidSql ); } // print_r($invoiceRecelvablesList); foreach ( $list as $key => $value ) { foreach ( $invoiceList as $k => $v ) { if ($value ['itid'] == $v ['trainId']) { $list [$key] ['invoiceTotalAmount'] = $v ['invoicePrice']; break; } } foreach ( $invoiceRecelvablesList as $i => $o ) { if ($value ['itid'] == $o ['trainId']) { $list [$key] ['invoiceArriveAmount'] = $o ['receivablesPrice']; $list [$key] ['arriveSchedule'] = "0"; if ($value ['invoiceTotal'] != 0) $list [$key] ['arriveSchedule'] = round ( $o ['count'] / $value ['invoiceTotal'] * 100, 2 ); break; } } } return $list; } /** * 根据参数字段更新相应字段(主键ID必须传) * @param array $item 相关需要更新的字段信息 * @return number 返回发票ID */ public function setInvoiceTrainByCondition($item = array(), $itid = "") { $lid = 0; if (is_array ( $item ) && ! empty ( $item )) { foreach ( $item as $key => $value ) { $this->$key = $value; } if (! empty ( $isid )) { $condition = array ( 'where' => "itid in (" . $itid . ")", 'asArray' => TRUE ); $this->update ( $condition ); } else $lid = $this->update (); } return $lid; } /** * 根据状态获取培训班 * @param number $status */ function getInvoiceTrainingByStatus($status = 0, $select = "", $cid = 0,$sid=0) { Doo::loadModel ( 'staff' ); $staff = new staff (); Doo::loadModel ( 'L_category' ); $lCategory = new L_category (); $condition = array ( 'where' => "status= '" . $status . "' and (cid=" . $cid." or creator=".$sid." )", 'limit' => 8, 'asArray' => TRUE ); if (! empty ( $select )) $condition += array ( 'select' => $select ); $list = $this->find ( $condition ); foreach ( $list as $key => $value ) { $detail = $staff->getStaffBySid ( $value ['creator'] ); $list [$key] ['staff'] = $detail; $detail = $lCategory->getCategoryById ( $value ['cid'] ); $list [$key] ['category'] = $detail; } return $list; } /** * 根据ID获得培训班 * @param number $itid */ function getInvoiceTrainingByItid($itid = 0) { Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); $itid = $XDeode->decode ( $itid ); $detail = array (); if (! empty ( $itid ) && is_numeric ( $itid )) { $detail = $this->getOne ( array ( 'where' => " itid=" . $itid, 'asArray' => TRUE ) ); } $detail ['trainingKey'] = ''; if (! empty ( $detail )) $detail ['trainingKey'] = $XDeode->encode ( $detail ['itid'] ); return $detail; } /** * 根据ID删除数据 * @param number $itid */ function delInvoiceTrainingByItid($itid = 0) { Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); $itid = $XDeode->decode ( $itid ); if (! empty ( $itid ) && is_numeric ( $itid )) $this->delete ( array ( 'where' => 'itid=' . $itid ) ); } } ?>