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');
 }
 public function actionLoad()
 {
     Payments::model()->deleteAll();
     Trucks::model()->deleteAll();
     ZReport::model()->deleteAll();
     $this->render("load");
 }
Exemple #3
0
 /**
  * Find a single truck based on their primary key!
  */
 public function actionTruck($id)
 {
     $truck = Trucks::get_truck_by_id($id);
     if (count($truck)) {
         $this->sendJsonResponse(array('status' => 'success', 'data' => $truck[0]));
     } else {
         $this->sendJsonResponse(array('status' => 'fail', 'data' => 'This truck does not exist..'));
     }
 }
 public function run($args)
 {
     $this->connection = new TwitterOAuth(Yii::app()->params['trucks']['twitter']['consumerKey'], Yii::app()->params['trucks']['twitter']['consumerSecret'], Yii::app()->params['trucks']['twitter']['oauthAccessToken'], Yii::app()->params['trucks']['twitter']['oauthAccessTokenSecret']);
     $mentions = $this->connection->get('statuses/mentions');
     $num_mentions = count($mentions);
     for ($i = $num_mentions - 1; $i >= 0; $i--) {
         $mention = $mentions[$i];
         $truck = Trucks::model()->findByAttributes(array('twitter_id' => $mention->user->id_str));
         if (NULL === $truck) {
             $message = 'SKIPPED: Tweet (id=' . $mention->id_str . ') is from an unauthorized Tweeter (@' . $mention->user->screen_name . ").\n";
             Yii::log($message, 'info', get_called_class());
             echo $message;
             continue;
         } elseif (TwitterHelper::isGeoLocatable($mention)) {
             if (TwitterHelper::isValidFormat($mention)) {
                 Yii::log("Tweet is valid. Checking for db insertion", 'info', get_called_class());
                 $truck_tweet = TrucksTweets::model()->findByAttributes(array('tweet_id' => $mention->id_str));
                 if (NULL === $truck_tweet) {
                     $parsed_tweet = TwitterHelper::parseTruckTweet($mention->text);
                     $truck_tweet = new TrucksTweets();
                     $truck_tweet->truck_id = $truck->id;
                     $truck_tweet->tweet = $mention->text;
                     $truck_tweet->tweet_id = $mention->id_str;
                     $truck_tweet->menu_url = $parsed_tweet['menu_url'];
                     $truck_tweet->start_time = TwitterHelper::convertTruckTime($mention->created_at, $parsed_tweet['start']);
                     $truck_tweet->end_time = TwitterHelper::convertTruckTime($mention->created_at, $parsed_tweet['end']);
                     $truck_tweet->geo_lat = $mention->coordinates->coordinates[1];
                     $truck_tweet->geo_long = $mention->coordinates->coordinates[0];
                     $truck_tweet->save();
                     $message = 'INSERTED: Tweet (text=' . $mention->text . ') from @' . $mention->user->screen_name . " successfully saved.\n";
                     Yii::log($message, 'info', get_called_class());
                     echo $message;
                 } else {
                     $message = 'SKIPPED: Tweet (id=' . $mention->id_str . ") already exists.\n";
                     Yii::log($message, 'info', get_called_class());
                     // Eating this output to save on cron tasks
                     // echo $message;
                     continue;
                 }
             } else {
                 $message = 'SKIPPED: Tweet (text=' . $mention->text . ") is an invalid format.\n";
                 Yii::log($message, 'info', get_called_class());
                 echo $message;
                 continue;
             }
         } else {
             $message = 'SKIPPED: Tweet (text=' . $mention->text . ') from ' . $mention->user->screen_name . " is not geo-locatable.\n";
             Yii::log($message, 'info', get_called_class());
             echo $message;
             continue;
         }
     }
 }
 public function actionList()
 {
     $criteria = new CDbCriteria();
     $criteria->order = "id desc";
     if ($_GET["search"] == 1) {
         $plates = explode(",", $_POST["plate"]);
         foreach ($plates as $plate) {
             $criteria->addSearchCondition("plate", trim(MYChtml::check_num($plate)), true, "OR");
         }
     }
     $count = Trucks::model()->count($criteria);
     $pages = new CPagination($count);
     // results per page
     $pages->pageSize = 30;
     $pages->applyLimit($criteria);
     $trucks = Trucks::model()->findAll($criteria);
     $this->render("list", array("trucks" => $trucks, 'pages' => $pages));
 }
Exemple #6
0
 public static function addBalanceFee($amountAddFee, $plate, $date = false)
 {
     $payment = new Payments();
     $payment->plate = $plate;
     $payment->amount_fee_license = $amountAddFee;
     $payment->amount_installation = 0;
     if ($date) {
         $payment->date = $date;
     } else {
         $payment->date = new CDbExpression('NOW()');
     }
     if ($payment->save()) {
         $truck = Trucks::model()->find("plate=:plate", array(":plate" => $plate));
         if ($truck) {
             $truck->balance_license_fee += $amountAddFee;
             $truck->save();
         }
         return true;
     } else {
         return false;
     }
 }
 /**
  * Find all the trucks in your company
  * @param mixed $_SESSION
  * @return all the trucks in your company
  **/
 public static function GetAssignableTrucks($cust)
 {
     $sql = "SELECT * FROM GPSTruck WHERE CustomerId = :cust";
     $params = array(':cust' => $cust);
     $stm = pdo_execute_query($sql, $params);
     if ($stm) {
         $stm->setFetchMode(PDO::FETCH_CLASS, "Trucks");
         $trucks = $stm->fetchAll();
         if ($trucks) {
             foreach ($trucks as &$truck) {
                 $truck->DisplayName = Trucks::calculateDisplayName($truck);
             }
             return $trucks;
         } else {
             return array();
         }
         //empty
     }
     return false;
 }
Exemple #8
0
 public static function checkPlate($plate)
 {
     $plate = MYChtml::check_num($plate);
     return Trucks::model()->find("plate=:plate", array(":plate" => $plate));
 }
<?php

session_start();
require '../_private/logo.php';
require '../lib/trucks.php';
mysql_select_db($db_name, $oConn);
//2014-09-16 Updated ^CS
$nh = Trucks::Retrieve($_GET['ID'], $_SESSION['customerId']);
$nh->ToggleActive();
$nh->ToggleUpdate();
header("Location: maps_trucks.php");
<?php

class Cars
{
    static $wheel_count = 4;
    /* The static method, car_detail(), returns the value of the 
    static property, $wheel_count. */
    static function car_detail()
    {
        /* The 'self' keyword is the same as using the '$this' pseudo-
        property in order to reference a property within the confines
        of the class it resides in. */
        return self::$wheel_count;
    }
}
class Trucks extends Cars
{
    static function display()
    {
        /* The 'parent' keyword references the class that 
        		the current class is extending. It can be used to 
        		call upon a parent class's methods or properties. */
        echo parent::car_detail();
    }
}
Trucks::display();
 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();
 }
 public function actionGetPayments($id)
 {
     $truck = Trucks::model()->findByPK($id);
     echo CJSON::encode($truck->payments);
 }
    $Identifier = $_POST['ID'];
    $truckdetails = Trucks::Retrieve($Identifier, $_SESSION['customerId']);
    $truck = new Trucks();
    $truck->ID = $_POST['ID'];
    $truck->TruckName = $truckdetails->TruckName;
    $truck->TruckID = $truckdetails->TruckID;
    $truck->TruckSerial = $truckdetails->TruckSerial;
    $truck->TruckPart = $truckdetails->TruckPart;
    $truck->TruckDriver = $_POST['TruckDriver'];
    $truck->CustomerId = $_SESSION['customerId'];
    $truck->Update();
    header("Location: maps_trucks.php#Truck");
    exit;
}
$ID = $_GET['ID'];
$truck = Trucks::Retrieve($ID, $_SESSION['customerId']);
$driving = $truck->TruckDriver;
?>

<form action="maps_editdriver.php" method="POST" enctype="application/x-www-form-urlencoded" id="edit_driver">
	<p>
		<label class="formstyle">Select New Driver : </label>
		<select class="validate" id="TruckDriver" name="TruckDriver">
			<option value='0'>Select...</option>
			<?php 
$drivers = PeopleAssignments::GetAssignableGPS($_SESSION['customerId']);
PeopleAssignments::RenderSelectOptions($drivers, $driving);
?>
		</select>
	</p>
	<p>
Exemple #14
0
 /**
  * Find a single truck based on their primary key!
  */
 public static function get_truck_by_id($id)
 {
     $id = (int) $id;
     $truck = Trucks::model()->with('trucksTweets:coords')->find(array('condition' => 't.id=:id', 'params' => array(':id' => $id)));
     $ret = array();
     if ($truck !== NULL) {
         $ret[] = Trucks::obj_to_array($truck);
     }
     return $ret;
 }
Exemple #15
0
        <div class="panel panel-primary-head">
            <div class="panel-heading">
                <h4 class="panel-title">Basic Configuration</h4>
                <p>Searching, ordering, paging etc goodness will be immediately added to the table, as shown in this example.</p>
            </div><!-- panel-heading -->
            <br><?php 
$f = fopen($_FILES['userfile']['tmp_name'], 'r');
$i = 0;
while (!feof($f)) {
    $i++;
    $data = fgetcsv($f, 1000, ";");
    if ((int) $data[4] > 0 and strlen($data[8]) > 3) {
        if (Trucks::checkPlate($data[8])) {
        } else {
            $truck = new Trucks();
            $truck->plate = MYChtml::check_num($data[8]);
            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 = "";
            }
<?php

require "inc_header_ps.php";
require '../_private/logo.php';
require_once '../lib/trucks.php';
require_once '../lib/PeopleAssignments.php';
mysql_select_db($db_name, $oConn);
// 2014-09-16 Truck Box Update ^CS
// 2014-06-16 Updated For New GPS ^CS
if ($_POST['save'] != "") {
    $truck = new Trucks();
    $truck->TruckName = $_POST['TruckName'];
    $truck->TruckID = $_POST['TruckID'];
    $truck->TruckSerial = $_POST['Serial'];
    $truck->TruckPart = $_POST['Part'];
    $truck->Truck = $_POST['yes'];
    $truck->CustomerId = $_SESSION['customerId'];
    $truck->InsertTruck();
    header("Location: maps_trucks.php#Truck");
    exit;
}
?>

<form action="maps_addtruck_truck.php" method="POST" enctype="application/x-www-form-urlencoded" id="truck_add">
<p>
	<label class="formstyle">Truck GPS Display Name :</label>
	<input type="text" class="validate" id="TruckName" name="TruckName"/><br />
</p>
<p>
	<label class="formstyle">Truck GPS Box MEID :</label>
	<input type="text" class="validate" id="TruckID" name="TruckID"/><br />
<?php

require "inc_header_ps.php";
require '../_private/logo.php';
require_once '../lib/trucks.php';
require_once '../lib/PeopleAssignments.php';
mysql_select_db($db_name, $oConn);
// 2014-09-16 Truck Box Update ^CS
// 2014-06-16 Updated For New GPS ^CS
if ($_POST['save'] != "") {
    $truck = new Trucks();
    $truck->TruckName = $_POST['TruckName'];
    $truck->TruckID = $_POST['TruckID'];
    $truck->CustomerId = $_SESSION['customerId'];
    $truck->Insert();
    header("Location: maps_trucks.php#Phone");
    exit;
}
?>

<form action="maps_addtruck.php" method="POST" enctype="application/x-www-form-urlencoded" id="truck_add">
	<p>
		<label class="formstyle">Select Driver:</label>
		<select class="validate" id="TruckID" name="TruckID">
			<option value='0'>Select...</option>
			<?php 
$drivers = PeopleAssignments::GetAssignableGPS($_SESSION['customerId']);
PeopleAssignments::RenderSelectOptions($drivers);
?>
		</select><br />
		<label class="formstyle">Driver GPS Display Name :</label>
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Trucks::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }