<td><?php echo InputType('text', 'cost', $arTs[0]["COST"], '', false, '', 'class="cost"'); ?> </td> </tr> <tr> <td class="title">Пробег</td> <td><?php echo InputType('text', 'odo', $arTs[0]["ODO"], '', false, '', 'class="odo"'); ?> </td> </tr> <tr> <td class="title">Путевая точка</td> <td><?php echo Lib\Points::showSelectPoints("ts_point", $arTs[0]["POINTS_ID"], 'class="ts_point"'); ?> </td> </tr> <tr> <td class="center" colspan="2">или</td> </tr> <tr> <td class="title">Имя новой точки</td> <td><?php echo InputType('text', 'newpoint_name', '', '', false, '', 'class="newpoint_name"'); ?> </td> </tr> <tr> <td class="title">Адрес новой точки</td>
<td><?php echo InputType('text', 'cost', '', '', false, '', 'class="cost"'); ?> </td> </tr> <tr> <td class="title">Пробег</td> <td><?php echo InputType('text', 'odo', '', '', false, '', 'class="odo"'); ?> </td> </tr> <tr> <td class="title">Путевая точка</td> <td><?php echo Lib\Points::showSelectPoints("ts_point", $lastPoint, 'class="ts_point"'); ?> </td> </tr> <tr> <td class="center" colspan="2">или</td> </tr> <tr> <td class="title">Имя новой точки</td> <td><?php echo InputType('text', 'newpoint_name', '', '', false, '', 'class="newpoint_name"'); ?> </td> </tr> <tr> <td class="title">Адрес новой точки</td>
<td><?php echo InputType('text', 'cost_liter', '', '', false, '', 'class="cost_liter"'); ?> </td> </tr> <tr> <td class="title">Полный бак</td> <td><?php echo InputType('checkbox', 'full_tank', 1, '', false, '', 'class="full_tank"'); ?> </td> </tr> <tr> <td class="title">Путевая точка</td> <td><?php echo Lib\Points::showSelectPoints("fuel_point", 'null', 'class="fuel_point"', array('fuel')); ?> </td> </tr> <tr> <td class="center" colspan="2">или</td> </tr> <tr> <td class="title">Имя новой точки</td> <td><?php echo InputType('text', 'newpoint_name', '', '', false, '', 'class="newpoint_name"'); ?> </td> </tr> <tr> <td class="title">Адрес новой точки</td>
<td><?php echo InputType('text', 'cost_liter', $arFuel['LITER_COST'], '', false, '', 'class="cost_liter"'); ?> </td> </tr> <tr> <td class="title">Полный бак</td> <td><?php echo InputType('checkbox', 'full_tank', 1, $arFuel['FULL'] ? 1 : 0, false, '', 'class="full_tank"'); ?> </td> </tr> <tr> <td class="title">Путевая точка</td> <td><?php echo Lib\Points::showSelectPoints("fuel_point", $arFuel['POINTS_ID'], 'class="fuel_point"', array('fuel')); ?> </td> </tr> <tr> <td class="center" colspan="2">или</td> </tr> <tr> <td class="title">Имя новой точки</td> <td><?php echo InputType('text', 'newpoint_name', '', '', false, '', 'class="newpoint_name"'); ?> </td> </tr> <tr> <td class="title">Адрес новой точки</td>
public static function addRepairPartsFromPost($post = null) { try { if (is_null($post)) { throw new Exception\ArgumentNullException('$arPost'); } } catch (Exception\ArgumentNullException $e) { die($e->showException()); } //msDebug($post); $arAdd = array(); if (!isset($post['my_car']) || intval($post['my_car']) <= 0) { $arAdd['MY_CAR_ID'] = MyCar::getDefaultCarID(); } else { $arAdd['MY_CAR_ID'] = intval($post['my_car']); } if (!isset($post['date']) || !CoreLib\DateHelper::checkDate($post['date'])) { static::$arError['DATE'] = 'Неверный формат даты'; return false; } else { if (!($arAdd['DATE'] = CoreLib\DateHelper::validateDate($post['date']))) { static::$arError['DATE'] = 'Неверный формат даты'; return false; } } if (!isset($post['name'])) { static::$arError['NAME'] = 'Не указано имя'; return false; } else { $arAdd['NAME'] = htmlspecialchars(trim($post['name'])); } if (!isset($post['storage']) || intval($post['storage']) <= 0) { static::$arError['STORAGE_ID'] = 'Не указано место хранения'; return false; } else { $arAdd['STORAGE_ID'] = intval($post['storage']); } if (isset($post['catalog_number']) && strlen($post['catalog_number']) > 0) { $arAdd['CATALOG_NUMBER'] = htmlspecialchars(trim($post['catalog_number'])); } if (!isset($post['number']) || floatval($post['number']) <= 0) { $arAdd['NUMBER'] = 1; } else { $arAdd['NUMBER'] = CoreLib\Tools::validateFloatVal($post['number']); } if (!isset($post['cost']) || floatval($post['cost']) <= 0) { $arAdd['COST'] = 0; } else { $arAdd['COST'] = CoreLib\Tools::validateFloatVal($post['cost']); } if (!isset($post['reason']) || intval($post['reason']) <= 0) { static::$arError['REASON_REPLACEMENT_ID'] = 'Не указана причина замены'; return false; } else { $arAdd['REASON_REPLACEMENT_ID'] = intval($post['reason']); } $reasonCode = ReasonReplacement::getCodeById($arAdd['REASON_REPLACEMENT_ID']); switch ($reasonCode) { case 'ts': $arAdd['TS_ID'] = intval($post['reason_ts']) > 0 ? intval($post['reason_ts']) : 0; break; case 'breakdown': $arAdd['REPAIR_ID'] = intval($post['reason_breakdown']) > 0 ? intval($post['reason_breakdown']) : 0; break; case 'tuning': $arAdd['REPAIR_ID'] = intval($post['reason_tuning']) > 0 ? intval($post['reason_tuning']) : 0; break; case 'upgrade': $arAdd['REPAIR_ID'] = intval($post['reason_upgrade']) > 0 ? intval($post['reason_upgrade']) : 0; break; case 'tire': break; case 'accident': $arAdd['ACCIDENT_ID'] = intval($post['reason_dtp']) > 0 ? intval($post['reason_dtp']) : 0; break; default: static::$arError['REASON_REPLACEMENT_DETAIL'] = 'Не указана дополнительная информация по причине замены'; return false; } if (!isset($post['who_paid']) || intval($post['who_paid']) <= 0) { static::$arError['WHO_PAID_ID'] = 'Не указано кто платил'; return false; } else { $arAdd['WHO_PAID_ID'] = intval($post['who_paid']); } if (!isset($post['odo']) || floatval($post['odo']) <= 0) { $arAdd['ODO'] = 0; } else { $arAdd['ODO'] = CoreLib\Tools::validateFloatVal($post['odo']); } if (isset($post['ts_point']) && intval($post['ts_point']) > 0) { $arAdd['POINTS_ID'] = intval($post['ts_point']); } else { if (isset($post['newpoint_address']) || isset($post['newpoint_lat']) && isset($post['newpoint_lon'])) { $arPoint = array(); if (isset($post['newpoint_name']) && strlen($post['newpoint_name']) > 0) { $arPoint['NAME'] = $post['newpoint_name']; } else { $arPoint['NAME'] = '[auto] Сервис'; } if (isset($post['newpoint_address']) && strlen($post['newpoint_address']) > 5) { $arPoint['ADDRESS'] = $post['newpoint_address']; } if (isset($post['newpoint_lat']) && strlen($post['newpoint_lat']) > 2 && (isset($post['newpoint_lon']) && strlen($post['newpoint_lon']) > 2)) { $arPoint['LON'] = $post['newpoint_lon']; $arPoint['LAT'] = $post['newpoint_lat']; } $arPoint['TYPE'] = Points::getPointTypeIdByCode('service'); if (!($arAdd['POINTS_ID'] = Points::createNewPoint($arPoint))) { unset($arAdd['POINTS_ID']); static::$arError['POINTS_ADD'] = 'Ошибка добавления путевой точки'; return false; } } else { static::$arError['POINTS_ID'] = 'Не указана путевая точка'; return false; } } if (isset($post['comment']) && strlen($post['comment']) > 0) { $arAdd['DESCRIPTION'] = trim(htmlspecialchars($post['comment'])); } return static::addRepairParts($arAdd); }
/** * Функция добавляет новый машрут и возвращает ID записи, либо false * * @param array $arData * * @return bool|int */ protected static function addNewRoute($arData = array()) { try { if (empty($arData)) { throw new Exception\ArgumentNullException('arNewRote'); } } catch (Exception\ArgumentNullException $e) { $e->showException(); return false; } if (isset($arData['end_point_num'])) { $bEndPoint = true; unset($arData['end_point_num']); } else { $bEndPoint = false; } $query = new Query('insert'); $query->setInsertParams(array(0 => $arData), Tables\RoutsTable::getTableName(), Tables\RoutsTable::getMapArray()); $res = $query->exec(); if ($res->getResult()) { if ($bEndPoint) { Points::increasePointPopular($arData['END_POINTS_ID']); } static::updateDayOdometer($arData['MY_CAR_ID'], $arData['DATE']); return $res->getInsertId(); } else { return false; } }
public static function updateTsFromPost($tsID = null, $post = null) { try { if (is_null($tsID)) { throw new Exception\ArgumentNullException('tsID'); } if (is_null($post)) { throw new Exception\ArgumentNullException('_POST'); } } catch (Exception\ArgumentNullException $e) { $e->showException(); return false; } //msDebug($post); $arUpdate = array(); if (isset($post['my_car']) || intval($post['my_car']) <= 0) { $arUpdate['MY_CAR_ID'] = intval($post['my_car']); } if (isset($post['ts_num'])) { $arUpdate['TS_NUM'] = intval($post['ts_num']); } if (isset($post['date']) && CoreLib\DateHelper::checkDate($post['date'])) { $arUpdate['DATE'] = CoreLib\DateHelper::validateDate($post['date']); } if (isset($post['executor']) && intval($post['executor']) <= 0) { $arUpdate['EXECUTORS_ID'] = intval($post['executor']); } if (isset($post['cost'])) { $post['cost'] = str_replace(" ", "", $post['cost']); $post['cost'] = str_replace(",", ".", $post['cost']); $post['cost'] = floatval($post['cost']); $arUpdate['COST'] = $post['cost']; } if (isset($post['odo'])) { $post['odo'] = str_replace(" ", "", $post['odo']); $post['odo'] = str_replace(",", ".", $post['odo']); $post['odo'] = floatval($post['odo']); $arUpdate['ODO'] = $post['odo']; } if (isset($post['ts_point']) && intval($post['ts_point']) > 0) { $arUpdate['POINTS_ID'] = intval($post['ts_point']); } else { if (isset($post['newpoint_address']) || isset($post['newpoint_lat']) && isset($post['newpoint_lon'])) { $arPoint = array(); if (isset($post['newpoint_name']) && strlen($post['newpoint_name']) > 3) { $arPoint['NAME'] = $post['newpoint_name']; } else { $arPoint['NAME'] = '[auto] Сервис'; } if (isset($post['newpoint_address']) && strlen($post['newpoint_address']) > 5) { $arPoint['ADDRESS'] = $post['newpoint_address']; } if (isset($post['newpoint_lat']) && strlen($post['newpoint_lat']) > 2 && (isset($post['newpoint_lon']) && strlen($post['newpoint_lon']) > 2)) { $arPoint['LON'] = $post['newpoint_lon']; $arPoint['LAT'] = $post['newpoint_lat']; } $arPoint['TYPE'] = Points::getPointTypeIdByCode('service'); $arUpdate['POINTS_ID'] = Points::createNewPoint($arPoint); } } if (isset($post['comment']) && strlen($post['comment']) > 0) { $arUpdate['DESCRIPTION'] = trim(htmlspecialchars($post['comment'])); } if ($res = static::updateTs($tsID, $arUpdate)) { return true; } else { return false; } }
<td><?php echo Lib\WhoPaid::showSelectWhoPaidList("who_paid", $bError ? intval($_POST['who_paid']) : 1); ?> </td> </tr> <tr> <td class="title">Пробег</td> <td><?php echo InputType('text', 'odo', $bError ? $_POST['odo'] : '', '', false, '', 'class="odo"'); ?> </td> </tr> <tr> <td class="title">Путевая точка</td> <td><?php echo Lib\Points::showSelectPoints("ts_point", $bError && intval($_POST['showSelectPoints']) > 0 ? intval($_POST['showSelectPoints']) : 'null'); ?> </td> </tr> <tr> <td class="center" colspan="2">или</td> </tr> <tr> <td class="title">Имя новой точки</td> <td><?php echo InputType('text', 'newpoint_name', $bError ? $_POST['newpoint_name'] : '', '', false, '', 'class="newpoint_name"'); ?> </td> </tr> <tr> <td class="title">Адрес новой точки</td>
/** * Добавляет данные о заправки в БД * * @param array $arData * * @return bool|int */ protected static function addFuel($arData = null) { try { if (is_null($arData)) { throw new Exception\ArgumentNullException('arData'); } elseif (!is_array($arData)) { throw new Exception\ArgumentTypeException('arData', 'array'); } } catch (Exception\ArgumentNullException $e) { die($e->showException()); } catch (Exception\ArgumentTypeException $e2) { die($e2->showException()); } $query = new Query('insert'); $query->setInsertParams($arData, Tables\FuelTable::getTableName(), Tables\FuelTable::getMapArray()); $res = $query->exec(); if ($res->getResult()) { Points::increasePointPopular($arData['POINTS_ID']); static::recalculateExpence($arData); return $res->getInsertId(); } else { return false; } }
<td class="value"><?php echo InputType('text', 'start_lon', '', '', false, '', 'class="start_lon"'); ?> </td> </tr> <tr> <td class="name">По городу</td> <td class="value"><?php echo InputType('checkbox', 'end_start', 1, '', false, '', 'class="end_start"'); ?> </td> </tr> <tr> <td class="name">Конечная путевая точка</td> <td class="value"><?php echo Lib\Points::showSelectPoints("end_point", 'null', 'class="end_point"'); ?> </td> </tr> <tr> <td class="name"> </td> <td class="value">или</td> </tr> <tr> <td class="name">Имя новой путевой точки</td> <td class="value"><?php echo InputType('text', 'end_name', '', '', false, '', 'class="end_name"'); ?> </td> </tr> <tr>