コード例 #1
0
ファイル: accident.php プロジェクト: msergeev06/mj-msergeev
 public static function getAccidentList($carID = null, $getID = null, $limit = 0, $offset = 0)
 {
     if (is_null($carID)) {
         $carID = MyCar::getDefaultCarID();
     }
     $arFilter = array();
     if (!is_null($getID) && intval($getID) > 0) {
         $arFilter["ID"] = intval($getID);
         $limit = 1;
     } else {
         $arFilter['MY_CAR_ID'] = $carID;
     }
     $arList = array('select' => array('ID', 'MY_CAR_ID', 'MY_CAR_ID.NAME' => 'MY_CAR_NAME', 'MY_CAR_ID.CAR_NUMBER' => 'MY_CAR_NUMBER', 'ACCIDENT_DATE', 'ODO', 'YOU_INSURANCE_ID', 'YOU_INSURANCE_ID.NAME' => 'YOU_INSURANCE_NAME', 'SECOND_INSURANCE_ID', 'SECOND_INSURANCE_ID.NAME' => 'SECOND_INSURANCE_NAME', 'DAMAGE_PARTS', 'EXECUTOR_ID', 'EXECUTOR_ID.NAME' => "EXECUTOR_NAME", 'EXECUTOR_ID.CODE' => "EXECUTOR_CODE", 'WHO_PAID_ID', 'WHO_PAID_ID.NAME' => 'WHO_PAID_NAME', 'WHO_PAID_ID.CODE' => 'WHO_PAID_CODE', 'INSURANCE_PAID', 'POINTS_ID', 'POINTS_ID.NAME' => 'POINT_NAME', 'POINTS_ID.LATITUDE' => 'POINT_LATITUDE', 'POINTS_ID.LONGITUDE' => 'POINT_LONGITUDE', 'POINTS_ID.POINT_TYPES_ID' => 'POINT_TYPE_ID', 'POINTS_ID.POINT_TYPES_ID.NAME' => 'POINT_TYPE_NAME', 'DESCRIPTION' => 'INFO'), 'filter' => $arFilter, 'order' => array('ACCIDENT_DATE' => 'ASC', 'ID' => 'ASC'));
     if ($limit > 0) {
         $arList['limit'] = $limit;
     }
     if ($offset > 0) {
         $arList['offset'] = $offset;
     }
     $arRes = AccidentTable::getList($arList);
     return $arRes;
 }
コード例 #2
0
 protected static function getRepairPartsList($carID = null, $getID = null, $limit = 0, $offset = 0)
 {
     if (is_null($carID)) {
         $carID = MyCar::getDefaultCarID();
     }
     $arFilter = array();
     if (!is_null($getID) && intval($getID) > 0) {
         $arFilter["ID"] = intval($getID);
         $limit = 1;
     } else {
         $arFilter['MY_CAR_ID'] = $carID;
     }
     $arList = array('select' => array('ID', 'MY_CAR_ID', 'DATE', 'NAME', 'STORAGE_ID', 'CATALOG_NUMBER', 'NUMBER', 'COST', 'REASON_REPLACEMENT_ID', 'TS_ID', 'ACCIDENT_ID', 'REPAIR_ID', 'WHO_PAID_ID', 'ODO', 'POINTS_ID', 'DESCRIPTION' => 'INFO'), 'filter' => $arFilter, 'order' => array('DATE' => 'ASC', 'ID' => 'ASC'));
     if ($limit > 0) {
         $arList['limit'] = $limit;
     }
     if ($offset > 0) {
         $arList['offset'] = $offset;
     }
     $arRes = Tables\RepairPartsTable::getList($arList);
     if ($arRes) {
         foreach ($arRes as $key => &$ar_res) {
             if ($ar_res['MY_CAR_ID'] > 0) {
                 $arRes2 = Tables\MyCarTable::getList(array('select' => array('NAME' => 'MY_CAR_NAME', 'CAR_NUMBER' => 'MY_CAR_NUMBER'), 'filter' => array('ID' => $ar_res['MY_CAR_ID']), 'limit' => 1));
                 if ($arRes2) {
                     $arRes2 = $arRes2[0];
                     if (isset($arRes2['ID'])) {
                         unset($arRes2['ID']);
                     }
                     $ar_res = array_merge($ar_res, $arRes2);
                 }
             }
             if ($ar_res['STORAGE_ID'] > 0) {
                 $arRes2 = Tables\StorageTable::getList(array('select' => array('NAME' => 'STORAGE_NAME', 'CODE' => 'STORAGE_CODE'), 'filter' => array('ID' => $ar_res['STORAGE_ID']), 'limit' => 1));
                 if ($arRes2) {
                     $arRes2 = $arRes2[0];
                     if (isset($arRes2['ID'])) {
                         unset($arRes2['ID']);
                     }
                     $ar_res = array_merge($ar_res, $arRes2);
                 }
             }
             if ($ar_res['REASON_REPLACEMENT_ID'] > 0) {
                 $arRes2 = Tables\ReasonReplacementTable::getList(array('select' => array('NAME' => 'REASON_REPLACEMENT_NAME', 'CODE' => 'REASON_REPLACEMENT_CODE')));
                 if ($arRes2) {
                     $arRes2 = $arRes2[0];
                     if (isset($arRes2['ID'])) {
                         unset($arRes2['ID']);
                     }
                     $ar_res = array_merge($ar_res, $arRes2);
                 }
             }
             if ($ar_res['TS_ID'] > 0) {
                 $arRes2 = Tables\TsTable::getList(array('select' => array('TS_NUM'), 'filter' => array('ID' => $ar_res['TS_ID']), 'limit' => 1));
                 if ($arRes2) {
                     $arRes2 = $arRes2[0];
                     if (isset($arRes2['ID'])) {
                         unset($arRes2['ID']);
                     }
                     $ar_res = array_merge($ar_res, $arRes2);
                 }
             }
             if ($ar_res['ACCIDENT_ID'] > 0) {
                 $arRes2 = Tables\AccidentTable::getList(array('select' => array('DESCRIPTION' => 'ACCIDENT_DESCRIPTION'), 'filter' => array('ID' => $ar_res['ACCIDENT_ID']), 'limit' => 1));
                 if ($arRes2) {
                     $arRes2 = $arRes2[0];
                     if (isset($arRes2['ID'])) {
                         unset($arRes2['ID']);
                     }
                     $ar_res = array_merge($ar_res, $arRes2);
                 }
             }
             if ($ar_res['REPAIR_ID'] > 0) {
                 $arRes2 = Tables\RepairTable::getList(array('select' => array('NAME' => 'REPAIR_NAME'), 'filter' => array('ID' => $ar_res['REPAIR_ID']), 'limit' => 1));
                 if ($arRes2) {
                     $arRes2 = $arRes2[0];
                     if (isset($arRes2['ID'])) {
                         unset($arRes2['ID']);
                     }
                     $ar_res = array_merge($ar_res, $arRes2);
                 }
             }
             if ($ar_res['WHO_PAID_ID'] > 0) {
                 $arRes2 = Tables\WhoPaidTable::getList(array('select' => array('NAME' => 'WHO_PAID_NAME', 'CODE' => 'WHO_PAID_CODE')));
                 if ($arRes2) {
                     $arRes2 = $arRes2[0];
                     if (isset($arRes2['ID'])) {
                         unset($arRes2['ID']);
                     }
                     $ar_res = array_merge($ar_res, $arRes2);
                 }
             }
             if ($ar_res['POINTS_ID'] > 0) {
                 $arRes2 = Tables\PointsTable::getList(array('select' => array('NAME' => 'POINT_NAME', 'LATITUDE' => 'POINT_LATITUDE', 'LONGITUDE' => 'POINT_LONGITUDE', 'POINT_TYPES_ID' => 'POINT_TYPE_ID', 'POINT_TYPES_ID.NAME' => 'POINT_TYPE_NAME'), 'filter' => array('ID' => $ar_res['POINTS_ID']), 'limit' => 1));
                 if ($arRes2) {
                     $arRes2 = $arRes2[0];
                     if (isset($arRes2['ID'])) {
                         unset($arRes2['ID']);
                     }
                     $ar_res = array_merge($ar_res, $arRes2);
                 }
             }
         }
         unset($ar_res);
     }
     //msDebug($arRes);
     return $arRes;
 }