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');
 }
Пример #2
0
 function actionCreateAndSendAccess()
 {
     if ($_POST['accounts'] == 0) {
         $account = new BncomplexAccount();
         $account->date_create = new CDbExpression("now()");
         //$account->forsearch
         $account->user = BNComplex::generateUserLogin();
         $account->forsearch = $account->user;
         $account->pass = BNComplex::generatePass();
         $account->phone = $_POST["phone"];
         $result = $account->save();
     } else {
         $account = BncomplexAccount::model()->find("user=:user", array(":user" => $_POST["accounts"]));
         $result = $account;
     }
     if ($result) {
         foreach ($_POST["plates"] as $plate) {
             if (strlen(str_replace(" ", "", $plate)) > 0) {
                 if (BncomplexSubscription::model()->count("plate=:plate and id_account=:account", array(":plate" => $plate, ":account" => $account->id)) == 0) {
                     $subs = new BncomplexSubscription();
                     $subs->id_account = $account->id;
                     $subs->plate = MYChtml::check_num($plate);
                     if (!$subs->save()) {
                         print_r($subs->getErrors());
                     }
                 }
             }
         }
     } else {
         echo "Пиздец" . $_POST["accounts"];
     }
     if ($account) {
         $BNLogin = BNComplex::createAccount($account);
         if ($BNLogin) {
         } else {
             echo "Опять пиздец";
         }
     }
     $this->render("createandsend", array("account" => $account, "isNew" => $_POST['accounts'] == 0 ? "Новый" : "Старый"));
 }
Пример #3
0
 public static function checkPlate($plate)
 {
     $plate = MYChtml::check_num($plate);
     return Trucks::model()->find("plate=:plate", array(":plate" => $plate));
 }
Пример #4
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();
 }
Пример #5
0
            $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;
            echo "<hr>";
        }
    }
    ob_start();
    echo "Строка " . $i . "<br>";
    ob_end_flush();
}
?>

        </div><!-- panel -->
Пример #6
0
 private function addSearch()
 {
     if (isset(Yii::app()->session['search'])) {
         foreach ($this->searchField as $val) {
             $this->criteria->addSearchCondition($val, Yii::app()->session['search'], true, "OR");
             $this->criteria->addSearchCondition($val, MYChtml::check_num(Yii::app()->session['search']), true, "OR");
         }
     }
 }