/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Driver();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Driver'])) {
         $model->attributes = $_POST['Driver'];
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function setUpCarsAndDrivers()
 {
     Doctrine::createTablesFromArray(array('Car', 'Driver'));
     $bmw = new Car();
     $bmw->make = 'BMW';
     $bmw->save();
     $this->cars['bmw'] = $bmw;
     $audi = new Car();
     $audi->make = 'Audi';
     $audi->save();
     $this->cars['audi'] = $audi;
     $kiro = new Driver();
     $kiro->name = 'Kiril Zyapkov';
     $kiro->save();
     $this->drivers['kiro'] = $kiro;
     $emo = new Driver();
     $emo->name = 'Emil Ivanov';
     $emo->save();
     $this->drivers['emo'] = $emo;
 }
Example #3
0
 public function save($filename = null, $permissions = null)
 {
     extract(parent::save($filename, $permissions));
     $this->run_queue();
     $this->add_background();
     $filetype = $this->image_extension;
     $old = '"' . $this->image_temp . '"';
     $new = '"' . $filename . '"';
     if (($filetype == 'jpeg' or $filetype == 'jpg') and $this->config['quality'] != 100) {
         $quality = '"' . $this->config['quality'] . '%"';
         $this->exec('convert', $old . ' -quality ' . $quality . ' ' . $new);
     } else {
         $this->exec('convert', $old . ' ' . $new);
     }
     if ($this->config['persistence'] === false) {
         $this->reload();
     }
     return $this;
 }
 public function saveNewDriver()
 {
     $code = Input::get('code');
     $first = Input::get('first');
     $last = Input::get('last');
     $email = Input::get('email');
     $password = Input::get('password');
     $gsmNumber = Input::get('gsm_number');
     $carId = Input::get('car_id');
     $timeZone = Input::get('time_zone');
     $languageId = Input::get('language_id');
     try {
         $user = new Users();
         $user->first = $first;
         $user->last = $last;
         $user->email = $email;
         $user->password = Hash::make($password);
         $user->role_id = Roles::DRIVER_ROLE_ID;
         $user->language_id = $languageId;
         $user->time_zone = $timeZone;
         $user->save();
         $driver = new Driver();
         $driver->user_id = $user->id;
         $driver->code = $code;
         $driver->first = $first;
         $driver->last = $last;
         $driver->gsm_number = $gsmNumber;
         $driver->car_id = $carId;
         $driver->save();
         $result = array('success' => true);
     } catch (Exception $ex) {
         \Log::error(__METHOD__ . ' | error :' . print_r($ex, 1));
         $result = array('success' => false);
     }
     return $result;
 }
 public function edit_help($user)
 {
     switch ($user->type) {
         case 'customer':
             Customer::where('id', '=', $user->id)->delete();
             break;
         case 'driver':
             Driver::where('id', '=', $user->id)->delete();
             break;
         case 'business':
             Business::where('id', '=', $user->id)->delete();
             break;
         default:
             break;
     }
     $user->type = Input::get('type');
     $user->save();
     switch (Input::get('type')) {
         case 'driver':
             $driver = new Driver();
             $driver->id = $user->id;
             $driver->first_name = Input::get('first_name');
             $driver->last_name = Input::get('last_name');
             $driver->phone = Input::get('phone');
             $driver->home_address = Input::get('address');
             $driver->credit_card = Input::get('credit_card');
             $driver->cvv = Input::get('cvv');
             $driver->expiry_date = Input::get('expiry_date');
             $driver->car_type = Input::get('car_type');
             $driver->cab_no = Input::get('cab_no');
             $driver->flag = Input::get('flag');
             $driver->rate = Input::get('rate');
             $driver->hour = Input::get('hour');
             $driver->save();
             break;
         case 'customer':
             $customer = new Customer();
             $customer->id = $user->id;
             $customer->first_name = Input::get('first_name');
             $customer->last_name = Input::get('last_name');
             $customer->phone = Input::get('phone');
             $customer->home_address = Input::get('address');
             $customer->credit_card = Input::get('credit_card');
             $customer->cvv = Input::get('cvv');
             $customer->expiry_date = Input::get('expiry_date');
             $customer->save();
             break;
         case 'business':
             $business = new Business();
             $business->id = $user->id;
             $business->business_name = Input::get('business_name');
             $business->phone = Input::get('phone');
             $business->home_address = Input::get('address');
             $business->credit_card = Input::get('credit_card');
             $business->cvv = Input::get('cvv');
             $business->expiry_date = Input::get('expiry_date');
             $business->save();
             break;
     }
 }
Example #6
0
 public function save($filename = null, $permissions = null)
 {
     extract(parent::save($filename, $permissions));
     $this->run_queue();
     $this->add_background();
     $filetype = $this->image_extension;
     if ($filetype == 'jpg' or $filetype == 'jpeg') {
         $filetype = 'jpeg';
     }
     if ($this->imagick->getImageFormat() != $filetype) {
         $this->imagick->setImageFormat($filetype);
     }
     if ($this->imagick->getImageFormat() == 'jpeg' and $this->config['quality'] != 100) {
         $this->imagick->setImageCompression(Fuel_Imagick::COMPRESSION_JPEG);
         $this->imagick->setImageCompressionQuality($this->config['quality']);
         $this->imagick->stripImage();
     }
     file_put_contents($filename, $this->imagick->getImageBlob());
     if ($this->config['persistence'] === false) {
         $this->reload();
     }
     return $this;
 }
Example #7
0
 public function post_add()
 {
     $files = Input::file('photo');
     $input = Input::all();
     try {
         unset($input['photo']);
         if (is_array($files) && isset($files['error']) && $files['error'] == 0) {
             $success = Resizer::open($files)->resize(200, 200, 'auto')->save(path('public') . 'photo/' . str_replace(' ', '-', $input['nip']) . '.jpg', 90);
         }
         //$input = $input + array('photo'=>str_replace(' ', '-', $input['nip']).'.jpg');
         //Driver::create($input);
         $driver = new Driver();
         $driver->name = $input['name'];
         $driver->nip = $input['nip'];
         $driver->ktp = $input['ktp'];
         $driver->sim = $input['sim'];
         $driver->phone = $input['phone'];
         $driver->brith_place = $input['brith_place'];
         $driver->date_of_birth = $input['date_of_birth'];
         $driver->address = $input['address'];
         $driver->kelurahan = $input['kelurahan'];
         $driver->kecamatan = $input['kecamatan'];
         $driver->kota = $input['kota'];
         $driver->fg_blocked = Input::get('fg_blocked', 0);
         $driver->driver_status = Input::get('driver_status', 2);
         $driver->kpp_validthrough = $input['kpp_validthrough'];
         $driver->city_id = $input['city_id'];
         $driver->pool_id = $input['pool_id'];
         $driver->pool_id = $input['pool_id'];
         if ($files) {
             $driver->photo = str_replace(' ', '-', $input['nip']) . '.jpg';
         }
         $driver->save();
         return Redirect::to('drivers');
     } catch (Exception $e) {
         return 'Error Insert';
     }
 }