public function actionCreate()
 {
     if ($_GET["select"] == 1) {
         //print_r($_POST);
         if (!Trucks::checkPlate($_POST["plate"])) {
             $truck = new Trucks();
             // print_r($_POST);
             $truck->plate = MYChtml::check_num($_POST["plate"]);
             /* if (strlen($data[1]) > 4) {$truck->is_conctract = 1; $truck->contract_number = $data[1];} else {$truck->is_conctract = 0; $truck->contract_number = "";}
                if (strlen($data[7]) > 4) {$truck->is_act = 1; $truck->act_number = $data[7];} else {$truck->is_act = 0; $truck->act_number = "";}*/
             $truck->balance_license_fee = (int) $_POST["amount_fee_license"];
             $truck->daily_license_fee = $_POST["weight"];
             $truck->comment = $_POST["comment"];
             $truck->fio = $_POST["fio"];
             if (!$truck->save()) {
                 print_r($truck->getErrors());
             }
         }
         $payment = new Payments();
         $payment->plate = MYChtml::check_num($_POST["plate"]);
         if ($_POST["amount_installation"] > 0) {
             $payment->amount_installation = (int) $_POST["amount_installation"];
         }
         if ($_POST["amount_fee_license"] > 0) {
             $payment->amount_fee_license = (int) $_POST["amount_fee_license"];
         }
         $payment->date = $_POST["date"];
         $payment->comment = $_POST["comment"];
         if (!$payment->save()) {
             print_r($payment->getErrors());
         }
     }
     $this->render('create');
 }
Example #2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Trucks();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Trucks'])) {
         $model->attributes = $_POST['Trucks'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 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();
 }
Example #4
0
     } else {
         $truck->is_conctract = 0;
         $truck->contract_number = "";
     }
     if (strlen($data[7]) > 4) {
         $truck->is_act = 1;
         $truck->act_number = $data[7];
     } else {
         $truck->is_act = 0;
         $truck->act_number = "";
     }
     $truck->balance_license_fee = 0;
     $truck->daily_license_fee = 10;
     $truck->comment = $data[0] . " ";
     $truck->fio = $data[3];
     if (!$truck->save()) {
         print_r($truck->getErrors());
         echo "<hr>";
         echo "Строка:" . $i;
         die;
     }
 }
 $payment = new Payments();
 $payment->amount_fee_license = 0;
 $payment->amount_installation = (int) $data[4];
 $payment->date = date("Y-m-d", strtotime($data[2]));
 $payment->plate = MYChtml::check_num($data[8]);
 if (!$payment->save()) {
     print_r($payment->getErrors());
     echo "Строка:" . $i;
     die;