コード例 #1
0
 function actionConfirmNewGlonass()
 {
     if (Trucks::checkPlate(MYChtml::check_num($this->plate))) {
         $this->ErrorCode = "1";
         $this->data["result"] = "Такой автомобиль уже существует";
     } else {
         $this->ErrorCode = "0";
         $this->data["result"] = "Предоплата за установку ГЛОНАСС авто " . MYChtml::check_num($this->plate);
         $truck = new Trucks();
         $truck->plate = MYChtml::check_num($_POST["plate"]);
         $cash = (double) $_POST["amount"];
         if ($cash >= self::$installationPrice) {
             $installFee = self::$installationPrice;
             $balanceFee = $cash - self::$installationPrice;
             $installation_is_close = 1;
         } else {
             $balanceFee = 0;
             $installFee = $cash;
             $installation_is_close = 0;
         }
         if (self::$yearLicenseFeePrice <= $balanceFee) {
             $truck->daily_license_fee = self::$yearLicenseFeePrice / 365;
         } else {
             $truck->daily_license_fee = self::$monthLicenseFeePrice / 30;
         }
         $truck->installation_is_close = $installation_is_close;
         $truck->balance_license_fee = $balanceFee;
         $truck->comment = "Через аппарат session = " . $this->SessionID . ", телефон " . $_POST['phone'];
         $truck->type = 0;
         if ($truck->save()) {
             Payments::addBalanceAndInstatllFee($balanceFee, $installFee, MYChtml::check_num($this->plate));
         } else {
             $this->ErrorCode = "1";
         }
     }
     $this->sendRequest();
 }