コード例 #1
0
 public function RejectedChequeByLiquidacionesId(Gyuser_Model_Cheques $obj)
 {
     $table = $this->getDbTable();
     $select = $table->select();
     $select->setIntegrityCheck(false);
     $Liquidacion_id = $obj->getLiquidacion_id();
     $select->from(array('cqu' => 'cheques'), array('id as cheque_id', 'operation_id', 'bank_account_id', 'date as cheque_date', 'check_n', 'amount', 'local', 'liquidacion_id', 'status as cheque_status', 'rejected_cost', 'rejected_cost_prov', 'credit_provider_id', 'rejected_type'));
     $select->joinLeft(array('ops' => 'operations'), 'cqu.operation_id = ops.id', array('client_id', 'bank_account_id'));
     $select->joinLeft(array('bas' => 'bank_accounts'), 'cqu.bank_account_id = bas.id', array('bank_name'));
     $select->joinLeft(array('cls' => 'clients'), 'ops.client_id = cls.id', array('first_name', 'last_name'));
     $select->joinLeft(array('chqs' => 'cheques_status'), 'cqu.status = chqs.id', array('id as cheque_state_id', 'status_list'));
     $select->joinLeft(array('lqd' => 'liquidaciones'), "lqd.id = {$Liquidacion_id}", array('date as liquidacion_date'));
     $select->where('cqu.status = ?', 3);
     //$select->where('cqu.date <= ?', date("Y-m-d"));
     $select->where('cqu.rejected_liquidacion_id = ?', $Liquidacion_id);
     $select->where('cqu.credit_provider_id IS NULL');
     //$select->where('cqu.status = ?', '');
     $select->order('cqu.id ASC');
     $resultSet = $table->fetchAll($select);
     $entries = array();
     foreach ($resultSet as $row) {
         $entry = array('id' => $row->cheque_id, 'date' => date("d/m/Y", strtotime($row->cheque_date)), 'liquidacion_date' => date("d/m/Y", strtotime($row->liquidacion_date)), 'check_n' => $row->check_n, 'amount' => $row->amount, 'status' => $row->cheque_state_id, 'status_name' => $row->status_list, 'local' => $row->local, 'bank_name' => $row->bank_name, 'first_name' => $row->first_name, 'last_name' => $row->last_name, 'rejected_cost' => $row->rejected_cost, 'rejected_type' => $row->rejected_type, 'cave_id' => $row->credit_provider_id, 'rejected_cost_prov' => $row->rejected_cost_prov);
         $entries[] = $entry;
     }
     return $entries;
 }