Ejemplo 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;
 }
Ejemplo n.º 2
0
 protected static function checkNeedIncreasePointPopular($pointID = null)
 {
     try {
         if (is_null($pointID)) {
             throw new Exception\ArgumentNullException('pointID');
         }
     } catch (Exception\ArgumentNullException $e) {
         $e->showException();
         return false;
     }
     $arRes = Tables\PointsTable::getList(array('select' => array('POPULAR'), 'filter' => array('ID' => $pointID)));
     if (isset($arRes[0]['POPULAR'])) {
         $nowPopular = $arRes[0]['POPULAR'];
     } else {
         return false;
     }
     //TODO: Проверить работу кода
     $arRes = Tables\PointsTable::getList(array('select' => array('ID'), 'filter' => array('>POPULAR' => $nowPopular, '<>ID' => $pointID)));
     /*		$helper = new SqlHelper();
     		$query = new Query('select');
     		$sql = 'SELECT '.$helper->wrapQuotes('ID').' FROM '
     			.$helper->wrapQuotes(Tables\PointsTable::getTableName())
     			.' WHERE '.$helper->wrapQuotes('POPULAR').' >= '.$nowPopular.' AND '
     			.$helper->wrapQuotes('ID').' <> '.$pointID;
     		$query->setQueryBuildParts($sql);
     		$query->setTableMap(Tables\PointsTable::getMapArray());
     		$query->setTableName(Tables\PointsTable::getTableName());
     		$res = $query->exec();*/
     //if ($ar_res = $res->fetch())
     if ($arRes) {
         return true;
     } else {
         return false;
     }
 }