/**
  * postEdit
  *
  * @param null $assetMaintenanceId
  *
  * @return mixed
  * @author  Vincent Sposato <*****@*****.**>
  * @version v1.0
  */
 public function postEdit($assetMaintenanceId = null)
 {
     // get the POST data
     $new = Input::all();
     // Check if the asset maintenance exists
     if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) {
         // Redirect to the asset maintenance management page
         return Redirect::to('admin/asset_maintenances')->with('error', Lang::get('admin/asset_maintenances/message.not_found'));
     }
     // attempt validation
     if ($assetMaintenance->validate($new)) {
         if (e(Input::get('supplier_id')) == '') {
             $assetMaintenance->supplier_id = null;
         } else {
             $assetMaintenance->supplier_id = e(Input::get('supplier_id'));
         }
         if (e(Input::get('is_warranty')) == '') {
             $assetMaintenance->is_warranty = 0;
         } else {
             $assetMaintenance->is_warranty = e(Input::get('is_warranty'));
         }
         if (e(Input::get('cost')) == '') {
             $assetMaintenance->cost = '';
         } else {
             $assetMaintenance->cost = ParseFloat(e(Input::get('cost')));
         }
         if (e(Input::get('notes')) == '') {
             $assetMaintenance->notes = null;
         } else {
             $assetMaintenance->notes = e(Input::get('notes'));
         }
         // Save the asset maintenance data
         $assetMaintenance->asset_id = e(Input::get('asset_id'));
         $assetMaintenance->asset_maintenance_type = e(Input::get('asset_maintenance_type'));
         $assetMaintenance->title = e(Input::get('title'));
         $assetMaintenance->start_date = e(Input::get('start_date'));
         $assetMaintenance->completion_date = e(Input::get('completion_date'));
         if ($assetMaintenance->completion_date == "" || $assetMaintenance->completion_date == "0000-00-00") {
             $assetMaintenance->completion_date = null;
             if ($assetMaintenance->asset_maintenance_time !== 0 || !is_null($assetMaintenance->asset_maintenance_time)) {
                 $assetMaintenance->asset_maintenance_time = null;
             }
         }
         if ($assetMaintenance->completion_date !== "" && $assetMaintenance->completion_date !== "0000-00-00" && $assetMaintenance->start_date !== "" && $assetMaintenance->start_date !== "0000-00-00") {
             $startDate = Carbon::parse($assetMaintenance->start_date);
             $completionDate = Carbon::parse($assetMaintenance->completion_date);
             $assetMaintenance->asset_maintenance_time = $completionDate->diffInDays($startDate);
         }
         // Was the asset maintenance created?
         if ($assetMaintenance->save()) {
             // Redirect to the new asset maintenance page
             return Redirect::to("admin/asset_maintenances")->with('success', Lang::get('admin/asset_maintenances/message.create.success'));
         }
     } else {
         // failure
         $errors = $assetMaintenance->errors();
         return Redirect::back()->withInput()->withErrors($errors);
     }
     // Redirect to the improvement create page
     return Redirect::to('admin/asset_maintenances/edit')->with('error', Lang::get('admin/asset_maintenances/message.create.error'))->with('assetMaintenance', $assetMaintenance);
 }
 /**
  * Asset update form processing page.
  *
  * @param  int  $assetId
  * @return Redirect
  */
 public function postEdit($assetId = null)
 {
     // Check if the asset exists
     if (is_null($asset = Asset::find($assetId))) {
         // Redirect to the asset management page with error
         return Redirect::to('hardware')->with('error', Lang::get('admin/hardware/message.does_not_exist'));
     }
     //attempt to validate
     $validator = Validator::make(Input::all(), $asset->validationRules($assetId));
     if ($validator->fails()) {
         // The given data did not pass validation
         return Redirect::back()->withInput()->withErrors($validator->messages());
     } else {
         if (e(Input::get('status_id')) == '') {
             $asset->status_id = NULL;
         } else {
             $asset->status_id = e(Input::get('status_id'));
         }
         if (e(Input::get('warranty_months')) == '') {
             $asset->warranty_months = NULL;
         } else {
             $asset->warranty_months = e(Input::get('warranty_months'));
         }
         if (e(Input::get('purchase_cost')) == '') {
             $asset->purchase_cost = NULL;
         } else {
             $asset->purchase_cost = ParseFloat(e(Input::get('purchase_cost')));
         }
         if (e(Input::get('purchase_date')) == '') {
             $asset->purchase_date = NULL;
         } else {
             $asset->purchase_date = e(Input::get('purchase_date'));
         }
         if (e(Input::get('supplier_id')) == '') {
             $asset->supplier_id = NULL;
         } else {
             $asset->supplier_id = e(Input::get('supplier_id'));
         }
         if (e(Input::get('requestable')) == '') {
             $asset->requestable = 0;
         } else {
             $asset->requestable = e(Input::get('requestable'));
         }
         // Update the asset data
         $asset->name = e(Input::get('name'));
         $asset->serial = e(Input::get('serial'));
         $asset->model_id = e(Input::get('model_id'));
         $asset->order_number = e(Input::get('order_number'));
         $asset->asset_tag = e(Input::get('asset_tag'));
         $asset->notes = e(Input::get('notes'));
         $asset->physical = '1';
         // Was the asset updated?
         if ($asset->save()) {
             // Redirect to the new asset page
             return Redirect::to("hardware/{$assetId}/view")->with('success', Lang::get('admin/hardware/message.update.success'));
         } else {
             return Redirect::to('hardware')->with('error', Lang::get('admin/hardware/message.does_not_exist'));
         }
     }
     // Redirect to the asset management page with error
     return Redirect::to("hardware/{$assetId}/edit")->with('error', Lang::get('admin/hardware/message.update.error'));
 }
 /**
  * License update form processing page.
  *
  * @param  int  $licenseId
  * @return Redirect
  */
 public function postEdit($licenseId = null)
 {
     // Check if the license exists
     if (is_null($license = License::find($licenseId))) {
         // Redirect to the blogs management page
         return Redirect::to('admin/licenses')->with('error', Lang::get('admin/licenses/message.does_not_exist'));
     }
     // get the POST data
     $new = Input::all();
     // attempt validation
     if ($license->validate($new)) {
         // Update the license data
         $license->name = e(Input::get('name'));
         $license->serial = e(Input::get('serial'));
         $license->license_email = e(Input::get('license_email'));
         $license->license_name = e(Input::get('license_name'));
         $license->notes = e(Input::get('notes'));
         $license->order_number = e(Input::get('order_number'));
         $license->depreciation_id = e(Input::get('depreciation_id'));
         $license->purchase_order = e(Input::get('purchase_order'));
         $license->maintained = e(Input::get('maintained'));
         $license->reassignable = e(Input::get('reassignable'));
         $license->type_id = e(Input::get('type_id'));
         $license->role_id = e(Input::get('role_id'));
         // Update the asset data
         if (e(Input::get('purchase_date')) == '') {
             $license->purchase_date = NULL;
         } else {
             $license->purchase_date = e(Input::get('purchase_date'));
         }
         if (e(Input::get('expiration_date')) == '') {
             $license->expiration_date = NULL;
         } else {
             $license->expiration_date = e(Input::get('expiration_date'));
         }
         // Update the asset data
         if (e(Input::get('termination_date')) == '') {
             $license->termination_date = NULL;
         } else {
             $license->termination_date = e(Input::get('termination_date'));
         }
         if (e(Input::get('purchase_cost')) == '') {
             $license->purchase_cost = NULL;
         } else {
             $license->purchase_cost = ParseFloat(e(Input::get('purchase_cost')));
             //$license->purchase_cost = e(Input::get('purchase_cost'));
         }
         if (e(Input::get('maintained')) == '') {
             $license->maintained = 0;
         } else {
             $license->maintained = e(Input::get('maintained'));
         }
         if (e(Input::get('reassignable')) == '') {
             $license->reassignable = 0;
         } else {
             $license->reassignable = e(Input::get('reassignable'));
         }
         if (e(Input::get('purchase_order')) == '') {
             $license->purchase_order = '';
         } else {
             $license->purchase_order = e(Input::get('purchase_order'));
         }
         //Are we changing the total number of seats?
         if ($license->seats != e(Input::get('seats'))) {
             //Determine how many seats we are dealing with
             $difference = e(Input::get('seats')) - $license->licenseseats()->count();
             if ($difference < 0) {
                 //Filter out any license which have a user attached;
                 $seats = $license->licenseseats->filter(function ($seat) {
                     return is_null($seat->user);
                 });
                 //If the remaining collection is as large or larger than the number of seats we want to delete
                 if ($seats->count() >= abs($difference)) {
                     for ($i = 1; $i <= abs($difference); $i++) {
                         //Delete the appropriate number of seats
                         $seats->pop()->delete();
                     }
                     //Log the deletion of seats to the log
                     $logaction = new Actionlog();
                     $logaction->asset_id = $license->id;
                     $logaction->asset_type = 'software';
                     $logaction->user_id = Sentry::getUser()->id;
                     $logaction->note = abs($difference) . " seats";
                     $logaction->checkedout_to = NULL;
                     $log = $logaction->logaction('delete seats');
                 } else {
                     // Redirect to the license edit page
                     return Redirect::to("admin/licenses/{$licenseId}/edit")->with('error', Lang::get('admin/licenses/message.assoc_users'));
                 }
             } else {
                 for ($i = 1; $i <= $difference; $i++) {
                     //Create a seat for this license
                     $license_seat = new LicenseSeat();
                     $license_seat->license_id = $license->id;
                     $license_seat->user_id = Sentry::getId();
                     $license_seat->assigned_to = NULL;
                     $license_seat->notes = NULL;
                     $license_seat->save();
                 }
                 //Log the addition of license to the log.
                 $logaction = new Actionlog();
                 $logaction->asset_id = $license->id;
                 $logaction->asset_type = 'software';
                 $logaction->user_id = Sentry::getUser()->id;
                 $logaction->note = abs($difference) . " seats";
                 $log = $logaction->logaction('add seats');
             }
             $license->seats = e(Input::get('seats'));
         }
         // Was the asset created?
         if ($license->save()) {
             // Redirect to the new license page
             return Redirect::to("admin/licenses/{$licenseId}/view")->with('success', Lang::get('admin/licenses/message.update.success'));
         }
     } else {
         // failure
         $errors = $license->errors();
         return Redirect::back()->withInput()->withErrors($errors);
     }
     // Redirect to the license edit page
     return Redirect::to("admin/licenses/{$licenseId}/edit")->with('error', Lang::get('admin/licenses/message.update.error'));
 }
Esempio n. 4
0
 //Veririfica se a linha é um boleto
 if ($comeco == "15209") {
     //Monta a string do boleto
     $numero_boleto = substr($linhas, 3, 17);
     //Monta a string do valor
     $valor_float = substr($linhas, 95, 11);
     //Converte a string para um decimal
     $valor_boleto = number_format(ParseFloat($valor_float), 2, ",", ".");
     //Monta a string do valor dos juros
     $valor_juros_float = substr($linhas, 115, 10);
     //Converte a string para um decimal
     $valor_juros_boleto = number_format(ParseFloat($valor_juros_float), 2, ",", ".");
     //echo $valor_boleto . "<br/>";
     //echo $valor_juros_boleto . "<br/>";
     $valor_retorno = number_format(ParseFloat($valor_float) + ParseFloat($valor_juros_float), 2, ",", ".");
     $valor_retorno_compara = number_format(ParseFloat($valor_float) + ParseFloat($valor_juros_float), 2, ".", "");
     $total_retorno = $total_retorno + $valor_retorno_compara;
     //Busca no banco de dados se existe o boleto
     //Monta a query para pegar os dados
     $sql_cli = "SELECT * FROM boleto WHERE nosso_numero = '{$numero_boleto}'";
     //Executa a query
     $query_cli = mysql_query($sql_cli);
     //Conta o numero de registros da query
     $registros_cli = mysql_num_rows($query_cli);
     //Caso não houver registros
     if ($registros_cli == 0) {
         $sacado = "<span style='color: #990000'><b>BOLETO NÃO ENCONTRADO !!!</b></span>";
         $cor_celula = "#F0D9D9";
         $marca_boleto = '';
         $desativa_chk = "disabled='disabled'";
         $valor_sacado = "R\$ 0,00";
 /**
  * Accessory update form processing page.
  *
  * @param  int  $accessoryId
  * @return Redirect
  */
 public function postEdit($accessoryId = null)
 {
     // Check if the blog post exists
     if (is_null($accessory = Accessory::find($accessoryId))) {
         // Redirect to the blogs management page
         return Redirect::to('admin/accessories')->with('error', Lang::get('admin/accessories/message.does_not_exist'));
     } else {
         if (!Company::isCurrentUserHasAccess($accessory)) {
             return Redirect::to('admin/accessories')->with('error', Lang::get('general.insufficient_permissions'));
         }
     }
     // get the POST data
     $new = Input::all();
     // attempt validation
     $validator = Validator::make(Input::all(), $accessory->validationRules($accessoryId));
     if ($validator->fails()) {
         // The given data did not pass validation
         return Redirect::back()->withInput()->withErrors($validator->messages());
     } else {
         // Update the accessory data
         $accessory->name = e(Input::get('name'));
         $accessory->location_id = e(Input::get('location_id'));
         $accessory->category_id = e(Input::get('category_id'));
         $accessory->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
         $accessory->order_number = e(Input::get('order_number'));
         if (e(Input::get('purchase_date')) == '') {
             $accessory->purchase_date = NULL;
         } else {
             $accessory->purchase_date = e(Input::get('purchase_date'));
         }
         if (e(Input::get('purchase_cost')) == '0.00') {
             $accessory->purchase_cost = NULL;
         } else {
             $accessory->purchase_cost = ParseFloat(e(Input::get('purchase_cost')));
         }
         $accessory->qty = e(Input::get('qty'));
         // Was the accessory created?
         if ($accessory->save()) {
             // Redirect to the new accessory page
             return Redirect::to("admin/accessories")->with('success', Lang::get('admin/accessories/message.update.success'));
         }
     }
     // Redirect to the accessory management page
     return Redirect::to("admin/accessories/{$accessoryID}/edit")->with('error', Lang::get('admin/accessories/message.update.error'));
 }
Esempio n. 6
0
 /**
  * Asset update form processing page.
  *
  * @param  int  $assetId
  * @return Redirect
  */
 public function postEdit($assetId = null)
 {
     // Check if the asset exists
     if (is_null($asset = Asset::find($assetId))) {
         // Redirect to the asset management page with error
         return Redirect::to('hardware')->with('error', Lang::get('admin/hardware/message.does_not_exist'));
     } else {
         if (!Company::isCurrentUserHasAccess($asset)) {
             return Redirect::to('hardware')->with('error', Lang::get('general.insufficient_permissions'));
         }
     }
     //attempt to validate
     $validator = Validator::make(Input::all(), $asset->validationRules($assetId));
     if ($validator->fails()) {
         // The given data did not pass validation
         return Redirect::back()->withInput()->withErrors($validator->messages());
     } else {
         if (e(Input::get('status_id')) == '') {
             $asset->status_id = NULL;
         } else {
             $asset->status_id = e(Input::get('status_id'));
         }
         if (e(Input::get('warranty_months')) == '') {
             $asset->warranty_months = NULL;
         } else {
             $asset->warranty_months = e(Input::get('warranty_months'));
         }
         if (e(Input::get('purchase_cost')) == '') {
             $asset->purchase_cost = NULL;
         } else {
             $asset->purchase_cost = ParseFloat(e(Input::get('purchase_cost')));
         }
         if (e(Input::get('purchase_date')) == '') {
             $asset->purchase_date = NULL;
         } else {
             $asset->purchase_date = e(Input::get('purchase_date'));
         }
         if (e(Input::get('supplier_id')) == '') {
             $asset->supplier_id = NULL;
         } else {
             $asset->supplier_id = e(Input::get('supplier_id'));
         }
         if (e(Input::get('requestable')) == '') {
             $asset->requestable = 0;
         } else {
             $asset->requestable = e(Input::get('requestable'));
         }
         if (e(Input::get('rtd_location_id')) == '') {
             $asset->rtd_location_id = 0;
         } else {
             $asset->rtd_location_id = e(Input::get('rtd_location_id'));
         }
         $checkModel = Config::get('app.url') . '/api/models/' . e(Input::get('model_id')) . '/check';
         $asset->mac_address = $checkModel == true ? e(Input::get('mac_address')) : NULL;
         // Update the asset data
         $asset->name = e(Input::get('name'));
         $asset->serial = e(Input::get('serial'));
         $asset->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
         $asset->model_id = e(Input::get('model_id'));
         $asset->order_number = e(Input::get('order_number'));
         $asset->asset_tag = e(Input::get('asset_tag'));
         $asset->notes = e(Input::get('notes'));
         $asset->physical = '1';
         // Update the image
         if (Input::file('image')) {
             $image = Input::file('image');
             $file_name = str_random(25) . "." . $image->getClientOriginalExtension();
             $path = public_path('uploads/assets/' . $file_name);
             Image::make($image->getRealPath())->resize(300, null, function ($constraint) {
                 $constraint->aspectRatio();
                 $constraint->upsize();
             })->save($path);
             $asset->image = $file_name;
         }
         // Was the asset updated?
         if ($asset->save()) {
             // Redirect to the new asset page
             return Redirect::to("hardware/{$assetId}/view")->with('success', Lang::get('admin/hardware/message.update.success'));
         } else {
             return Redirect::to('hardware')->with('error', Lang::get('admin/hardware/message.does_not_exist'));
         }
     }
     // Redirect to the asset management page with error
     return Redirect::to("hardware/{$assetId}/edit")->with('error', Lang::get('admin/hardware/message.update.error'));
 }
Esempio n. 7
0
 /**
  * Asset update form processing page.
  *
  * @param  int  $assetId
  * @return Redirect
  */
 public function postEdit($assetId = null)
 {
     // Check if the asset exists
     if (is_null($asset = Asset::find($assetId))) {
         // Redirect to the asset management page with error
         return Redirect::to('hardware')->with('error', Lang::get('admin/hardware/message.does_not_exist'));
     } else {
         if (!Company::isCurrentUserHasAccess($asset)) {
             return Redirect::to('hardware')->with('error', Lang::get('general.insufficient_permissions'));
         }
     }
     $input = Input::all();
     // return "INPUT IS: <pre>".print_r($input,true)."</pre>";
     $rules = $asset->validationRules($assetId);
     $model = Model::find(e(Input::get('model_id')));
     //validate by the NEW model's custom fields, not the current one
     if ($model->fieldset) {
         foreach ($model->fieldset->fields as $field) {
             $input[$field->db_column_name()] = $input['fields'][$field->db_column_name()];
             $asset->{$field->db_column_name()} = $input[$field->db_column_name()];
         }
         $rules += $model->fieldset->validation_rules();
         unset($input['fields']);
     }
     //return "Rules: <pre>".print_r($rules,true)."</pre>";
     //attempt to validate
     $validator = Validator::make($input, $rules);
     $custom_errors = [];
     if ($validator->fails()) {
         // The given data did not pass validation
         return Redirect::back()->withInput()->withErrors($validator->messages());
     } else {
         if (e(Input::get('status_id')) == '') {
             $asset->status_id = NULL;
         } else {
             $asset->status_id = e(Input::get('status_id'));
         }
         if (e(Input::get('warranty_months')) == '') {
             $asset->warranty_months = NULL;
         } else {
             $asset->warranty_months = e(Input::get('warranty_months'));
         }
         if (e(Input::get('purchase_cost')) == '') {
             $asset->purchase_cost = NULL;
         } else {
             $asset->purchase_cost = ParseFloat(e(Input::get('purchase_cost')));
         }
         if (e(Input::get('purchase_date')) == '') {
             $asset->purchase_date = NULL;
         } else {
             $asset->purchase_date = e(Input::get('purchase_date'));
         }
         if (e(Input::get('supplier_id')) == '') {
             $asset->supplier_id = NULL;
         } else {
             $asset->supplier_id = e(Input::get('supplier_id'));
         }
         if (e(Input::get('requestable')) == '') {
             $asset->requestable = 0;
         } else {
             $asset->requestable = e(Input::get('requestable'));
         }
         if (e(Input::get('rtd_location_id')) == '') {
             $asset->rtd_location_id = 0;
         } else {
             $asset->rtd_location_id = e(Input::get('rtd_location_id'));
         }
         if (Input::has('image_delete')) {
             unlink(public_path() . '/uploads/assets/' . $asset->image);
             $asset->image = '';
         }
         $checkModel = Config::get('app.url') . '/api/models/' . e(Input::get('model_id')) . '/check';
         //$asset->mac_address = ($checkModel == true) ? e(Input::get('mac_address')) : NULL;
         // Update the asset data
         $asset->name = e(Input::get('name'));
         $asset->serial = e(Input::get('serial'));
         $asset->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
         $asset->model_id = e(Input::get('model_id'));
         $asset->order_number = e(Input::get('order_number'));
         $asset->asset_tag = e(Input::get('asset_tag'));
         $asset->notes = e(Input::get('notes'));
         $asset->physical = '1';
         // Update the image
         if (Input::file('image')) {
             $image = Input::file('image');
             $file_name = str_random(25) . "." . $image->getClientOriginalExtension();
             $path = public_path('uploads/assets/' . $file_name);
             Image::make($image->getRealPath())->resize(300, null, function ($constraint) {
                 $constraint->aspectRatio();
                 $constraint->upsize();
             })->save($path);
             $asset->image = $file_name;
         }
         // Was the asset updated?
         if ($asset->save()) {
             // Redirect to the new asset page
             return Redirect::to("hardware/{$assetId}/view")->with('success', Lang::get('admin/hardware/message.update.success'));
         } else {
             return Redirect::to('hardware')->with('error', Lang::get('admin/hardware/message.does_not_exist'));
         }
     }
     // Redirect to the asset management page with error
     /** @noinspection PhpUnreachableStatementInspection Known to be unreachable but kept following discussion: https://github.com/snipe/snipe-it/pull/1423 */
     return Redirect::to("hardware/{$assetId}/edit")->with('error', Lang::get('admin/hardware/message.update.error'));
 }
Esempio n. 8
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $filename = $this->argument('filename');
     if (!$this->option('testrun') == 'true') {
         $this->comment('======= Importing Assets from ' . $filename . ' =========');
     } else {
         $this->comment('====== TEST ONLY Asset Import for ' . $filename . ' ====');
         $this->comment('============== NO DATA WILL BE WRITTEN ==============');
     }
     if (!ini_get("auto_detect_line_endings")) {
         ini_set("auto_detect_line_endings", '1');
     }
     $csv = Reader::createFromPath($this->argument('filename'));
     $csv->setNewline("\r\n");
     $csv->setOffset(1);
     $duplicates = '';
     // Loop through the records
     $nbInsert = $csv->each(function ($row) use($duplicates) {
         $status_id = 1;
         // Let's just map some of these entries to more user friendly words
         // User's name
         if (array_key_exists('0', $row)) {
             $user_name = trim($row[0]);
         } else {
             $user_name = '';
         }
         // User's email
         if (array_key_exists('1', $row)) {
             $user_email = trim($row[1]);
         } else {
             $user_email = '';
         }
         // User's email
         if (array_key_exists('2', $row)) {
             $user_username = trim($row[2]);
         } else {
             $user_username = '';
         }
         // Asset Name
         if (array_key_exists('3', $row)) {
             $user_asset_asset_name = trim($row[3]);
         } else {
             $user_asset_asset_name = '';
         }
         // Asset Category
         if (array_key_exists('4', $row)) {
             $user_asset_category = trim($row[4]);
         } else {
             $user_asset_category = '';
         }
         // Asset Name
         if (array_key_exists('5', $row)) {
             $user_asset_name = trim($row[5]);
         } else {
             $user_asset_name = '';
         }
         // Asset Manufacturer
         if (array_key_exists('6', $row)) {
             $user_asset_mfgr = trim($row[6]);
         } else {
             $user_asset_mfgr = '';
         }
         // Asset model number
         if (array_key_exists('7', $row)) {
             $user_asset_modelno = trim($row[7]);
         } else {
             $user_asset_modelno = '';
         }
         // Asset serial number
         if (array_key_exists('8', $row)) {
             $user_asset_serial = trim($row[8]);
         } else {
             $user_asset_serial = '';
         }
         // Asset tag
         if (array_key_exists('9', $row)) {
             $user_asset_tag = trim($row[9]);
         } else {
             $user_asset_tag = '';
         }
         // Asset location
         if (array_key_exists('10', $row)) {
             $user_asset_location = trim($row[10]);
         } else {
             $user_asset_location = '';
         }
         // Asset notes
         if (array_key_exists('11', $row)) {
             $user_asset_notes = trim($row[11]);
         } else {
             $user_asset_notes = '';
         }
         // Asset purchase date
         if (array_key_exists('12', $row)) {
             if ($row[12] != '') {
                 $user_asset_purchase_date = date("Y-m-d 00:00:01", strtotime($row[12]));
             } else {
                 $user_asset_purchase_date = '';
             }
         } else {
             $user_asset_purchase_date = '';
         }
         // Asset purchase cost
         if (array_key_exists('13', $row)) {
             if ($row[13] != '') {
                 $user_asset_purchase_cost = trim($row[13]);
             } else {
                 $user_asset_purchase_cost = '';
             }
         } else {
             $user_asset_purchase_cost = '';
         }
         // Asset Company Name
         if (array_key_exists('14', $row)) {
             if ($row[14] != '') {
                 $user_asset_company_name = trim($row[14]);
             } else {
                 $user_asset_company_name = '';
             }
         } else {
             $user_asset_company_name = '';
         }
         // A number was given instead of a name
         if (is_numeric($user_name)) {
             $this->comment('User ' . $user_name . ' is not a name - assume this user already exists');
             $user_username = '';
             // No name was given
         } elseif ($user_name == '') {
             $this->comment('No user data provided - skipping user creation, just adding asset');
             $first_name = '';
             $last_name = '';
             //$user_username = '';
         } else {
             $user_email_array = User::generateFormattedNameFromFullName($this->option('email_format'), $user_name);
             $first_name = $user_email_array['first_name'];
             $last_name = $user_email_array['last_name'];
             if ($user_email == '') {
                 $user_email = $user_email_array['username'] . '@' . Config::get('app.domain');
             }
             if ($user_username == '') {
                 if ($this->option('username_format') == 'email') {
                     $user_username = $user_email;
                 } else {
                     $user_name_array = User::generateFormattedNameFromFullName($this->option('username_format'), $user_name);
                     $user_username = $user_name_array['username'];
                 }
             }
         }
         $this->comment('Full Name: ' . $user_name);
         $this->comment('First Name: ' . $first_name);
         $this->comment('Last Name: ' . $last_name);
         $this->comment('Username: '******'Email: ' . $user_email);
         $this->comment('Category Name: ' . $user_asset_category);
         $this->comment('Item: ' . $user_asset_name);
         $this->comment('Manufacturer ID: ' . $user_asset_mfgr);
         $this->comment('Model No: ' . $user_asset_modelno);
         $this->comment('Serial No: ' . $user_asset_serial);
         $this->comment('Asset Tag: ' . $user_asset_tag);
         $this->comment('Location: ' . $user_asset_location);
         $this->comment('Purchase Date: ' . $user_asset_purchase_date);
         $this->comment('Purchase Cost: ' . $user_asset_purchase_cost);
         $this->comment('Notes: ' . $user_asset_notes);
         $this->comment('Company Name: ' . $user_asset_company_name);
         $this->comment('------------- Action Summary ----------------');
         if ($user_username != '') {
             if ($user = User::MatchEmailOrUsername($user_username, $user_email)->whereNotNull('username')->first()) {
                 $this->comment('User ' . $user_username . ' already exists');
             } else {
                 // Create the user
                 $user = Sentry::createUser(array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $user_email, 'username' => $user_username, 'password' => substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 12), 'activated' => true, 'permissions' => array('admin' => 0, 'user' => 1), 'notes' => 'User imported through asset importer'));
                 // Find the group using the group id
                 $userGroup = Sentry::findGroupById(3);
                 // Assign the group to the user
                 $user->addGroup($userGroup);
                 $this->comment('User ' . $first_name . ' created');
             }
         } else {
             $user = new User();
         }
         // Check for the location match and create it if it doesn't exist
         if ($location = Location::where('name', e($user_asset_location))->first()) {
             $this->comment('Location ' . $user_asset_location . ' already exists');
         } else {
             $location = new Location();
             if ($user_asset_location != '') {
                 $location->name = e($user_asset_location);
                 $location->address = '';
                 $location->city = '';
                 $location->state = '';
                 $location->country = '';
                 $location->user_id = 1;
                 if (!$this->option('testrun') == 'true') {
                     if ($location->save()) {
                         $this->comment('Location ' . $user_asset_location . ' was created');
                     } else {
                         $this->comment('Something went wrong! Location ' . $user_asset_location . ' was NOT created');
                     }
                 } else {
                     $this->comment('Location ' . $user_asset_location . ' was (not) created - test run only');
                 }
             } else {
                 $this->comment('No location given, so none created.');
             }
         }
         if (e($user_asset_category) == '') {
             $category_name = 'Unnamed Category';
         } else {
             $category_name = e($user_asset_category);
         }
         // Check for the category match and create it if it doesn't exist
         if ($category = Category::where('name', e($category_name))->where('category_type', 'asset')->first()) {
             $this->comment('Category ' . $category_name . ' already exists');
         } else {
             $category = new Category();
             $category->name = e($category_name);
             $category->category_type = 'asset';
             $category->user_id = 1;
             if ($category->save()) {
                 $this->comment('Category ' . $user_asset_category . ' was created');
             } else {
                 $this->comment('Something went wrong! Category ' . $user_asset_category . ' was NOT created');
             }
         }
         // Check for the manufacturer match and create it if it doesn't exist
         if ($manufacturer = Manufacturer::where('name', e($user_asset_mfgr))->first()) {
             $this->comment('Manufacturer ' . $user_asset_mfgr . ' already exists');
         } else {
             $manufacturer = new Manufacturer();
             $manufacturer->name = e($user_asset_mfgr);
             $manufacturer->user_id = 1;
             if ($manufacturer->save()) {
                 $this->comment('Manufacturer ' . $user_asset_mfgr . ' was created');
             } else {
                 $this->comment('Something went wrong! Manufacturer ' . $user_asset_mfgr . ' was NOT created');
             }
         }
         // Check for the asset model match and create it if it doesn't exist
         if ($asset_model = Model::where('name', e($user_asset_name))->where('modelno', e($user_asset_modelno))->where('category_id', $category->id)->where('manufacturer_id', $manufacturer->id)->first()) {
             $this->comment('The Asset Model ' . $user_asset_name . ' with model number ' . $user_asset_modelno . ' already exists');
         } else {
             $asset_model = new Model();
             $asset_model->name = e($user_asset_name);
             $asset_model->manufacturer_id = $manufacturer->id;
             $asset_model->modelno = e($user_asset_modelno);
             $asset_model->category_id = $category->id;
             $asset_model->user_id = 1;
             if ($asset_model->save()) {
                 $this->comment('Asset Model ' . $user_asset_name . ' with model number ' . $user_asset_modelno . ' was created');
             } else {
                 $this->comment('Something went wrong! Asset Model ' . $user_asset_name . ' was NOT created');
             }
         }
         // Check for the asset company match and create it if it doesn't exist
         if ($user_asset_company_name != '') {
             if ($company = Company::where('name', e($user_asset_company_name))->first()) {
                 $this->comment('Company ' . $user_asset_company_name . ' already exists');
             } else {
                 $company = new Company();
                 $company->name = e($user_asset_company_name);
                 if ($company->save()) {
                     $this->comment('Company ' . $user_asset_company_name . ' was created');
                 } else {
                     $this->comment('Something went wrong! Company ' . $user_asset_company_name . ' was NOT created');
                 }
             }
         } else {
             $company = new Company();
         }
         // Check for the asset match and create it if it doesn't exist
         if ($asset = Asset::where('asset_tag', e($user_asset_tag))->first()) {
             $this->comment('The Asset with asset tag ' . $user_asset_tag . ' already exists');
         } else {
             $asset = new Asset();
             $asset->name = e($user_asset_asset_name);
             if ($user_asset_purchase_date != '') {
                 $asset->purchase_date = $user_asset_purchase_date;
             } else {
                 $asset->purchase_date = NULL;
             }
             if ($user_asset_purchase_cost != '') {
                 $asset->purchase_cost = ParseFloat(e($user_asset_purchase_cost));
             } else {
                 $asset->purchase_cost = 0.0;
             }
             $asset->serial = e($user_asset_serial);
             $asset->asset_tag = e($user_asset_tag);
             $asset->model_id = $asset_model->id;
             $asset->assigned_to = $user->id;
             $asset->rtd_location_id = $location->id;
             $asset->user_id = 1;
             $asset->status_id = $status_id;
             $asset->company_id = $company->id;
             if ($user_asset_purchase_date != '') {
                 $asset->purchase_date = $user_asset_purchase_date;
             } else {
                 $asset->purchase_date = NULL;
             }
             $asset->notes = e($user_asset_notes);
             if ($asset->save()) {
                 $this->comment('Asset ' . $user_asset_name . ' with serial number ' . $user_asset_serial . ' was created');
             } else {
                 $this->comment('Something went wrong! Asset ' . $user_asset_name . ' was NOT created');
             }
         }
         $this->comment('=====================================');
         return true;
     });
 }
 $i++;
 if ($linha > 9) {
     $comeco = substr($linhas, 3, 5);
     //Veririfica se a linha é um boleto
     if ($comeco == "15209") {
         //Monta a string do boleto
         $numero_boleto = substr($linhas, 3, 17);
         //Monta a string do valor
         $valor_float = substr($linhas, 95, 11);
         //Converte a string para um decimal
         $valor_boleto = ParseFloat($valor_float);
         $valor_boleto_formata = number_format(ParseFloat($valor_float), 2, ",", ".");
         //Monta a string do valor dos juros
         $valor_juros_float = substr($linhas, 115, 10);
         //Converte a string para um decimal
         $valor_juros_boleto = number_format(ParseFloat($valor_juros_float), 2, ",", ".");
         //Busca no banco de dados se existe o boleto
         //Monta a query para pegar os dados
         $sql_cli = "SELECT * FROM boleto WHERE nosso_numero = '{$numero_boleto}' ORDER BY sacado";
         //Executa a query
         $query_cli = mysql_query($sql_cli);
         //Conta o numero de registros da query
         $registros_cli = mysql_num_rows($query_cli);
         //Caso não houver registros
         if ($registros_cli == 0) {
             $string_boletos_antigos .= "<br/>Boleto <b>{$numero_boleto}</b> BOLETO NÃO ENCONTRADO - ANTIGOS - REGISTRO BB - NÃO SERÁ PROCESSADO !";
             //Gera um lançamento na base de retornos processados com o status de não encontrado (3)
             $sql = "INSERT INTO retornos (\n        \t\t\tdata_processamento,\n        \t\t\ttitulo, \n        \t\t\tvalor,\n        \t\t\tstatus\n        \t\t\t) values (\n        \t\t\t'{$dataProcessa}',\n        \t\t\t'{$numero_boleto}',\n        \t\t\t'{$valor_boleto}',\n        \t\t\t'3'\n        \t\t\t);";
             mysql_query($sql);
         } else {
             //efetua o loop na pesquisa
Esempio n. 10
0
 /**
  * Consumable update form processing page.
  *
  * @param  int  $consumableId
  * @return Redirect
  */
 public function postEdit($consumableId = null)
 {
     // Check if the blog post exists
     if (is_null($consumable = Consumable::find($consumableId))) {
         // Redirect to the blogs management page
         return Redirect::to('admin/consumables')->with('error', Lang::get('admin/consumables/message.does_not_exist'));
     }
     // get the POST data
     $new = Input::all();
     // attempt validation
     $validator = Validator::make(Input::all(), $consumable->validationRules($consumableId));
     if ($validator->fails()) {
         // The given data did not pass validation
         return Redirect::back()->withInput()->withErrors($validator->messages());
     } else {
         // Update the consumable data
         $consumable->name = e(Input::get('name'));
         $consumable->category_id = e(Input::get('category_id'));
         $consumable->order_number = e(Input::get('order_number'));
         if (e(Input::get('purchase_date')) == '') {
             $consumable->purchase_date = NULL;
         } else {
             $consumable->purchase_date = e(Input::get('purchase_date'));
         }
         if (e(Input::get('purchase_cost')) == '0.00') {
             $consumable->purchase_cost = NULL;
         } else {
             $consumable->purchase_cost = ParseFloat(e(Input::get('purchase_cost')));
         }
         $consumable->qty = e(Input::get('qty'));
         // Was the consumable created?
         if ($consumable->save()) {
             // Redirect to the new consumable page
             return Redirect::to("admin/consumables")->with('success', Lang::get('admin/consumables/message.update.success'));
         }
     }
     // Redirect to the consumable management page
     return Redirect::to("admin/consumables/{$consumableID}/edit")->with('error', Lang::get('admin/consumables/message.update.error'));
 }