コード例 #1
0
 public function GetOperationsIdByLiquidacionIdJson(Gyuser_Model_Operations $obj)
 {
     $table = $this->getDbTable();
     $select = $table->select();
     $select->setIntegrityCheck(false);
     $select->from(array('opr' => 'operations'), array('id', 'client_id', 'date', 'amount', 'observations', 'report', 'date_added', 'state_order_id', 'cave_id'));
     $select->joinLeft(array('ocvs' => 'other_caves'), 'opr.cave_id = ocvs.id', array('name as cave_name'));
     $select->joinLeft(array('cls' => 'clients'), 'opr.client_id = cls.id', array('first_name', 'last_name'));
     $select->where('opr.liquidacion_id =?', $obj->getLiquidacion_id());
     $select->order('opr.id ASC');
     $resultSet = $table->fetchAll($select);
     if ($resultSet) {
         $entries = array();
         foreach ($resultSet as $row) {
             $operationid = $row->id;
             $entry = array('stateid' => $row->state_order_id, 'operationid' => $operationid, 'amount' => $row->amount, 'date' => date("d/m/Y", strtotime($row->date)), 'cave_id' => $row->cave_id, 'cave_name' => $row->cave_name, 'first_name' => $row->first_name, 'last_name' => $row->last_name);
             $entries[$operationid] = $entry;
         }
         return $entries;
     } else {
         return null;
     }
 }