Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
 public static function showSelectWhoPaidList($strBoxName, $selected = 1, $field1 = "class=\"whopaidselect\"")
 {
     $arRes = WhoPaidTable::getList(array('select' => array('ID' => 'VALUE', 'NAME'), 'filter' => array('ACTIVE' => true), 'order' => array('SORT' => 'ASC')));
     return SelectBox($strBoxName, $arRes, '', $selected, $field1);
 }