コード例 #1
0
ファイル: cestimates.php プロジェクト: imranweb7/msitc-erp
 function createShippingEstimate()
 {
     $this->load->helper('notification');
     $this->view_data['submenu'] = array();
     if ($_POST) {
         unset($_POST['send']);
         unset($_POST['files']);
         $_POST['shipping_lebel'] = '';
         $config['upload_path'] = './files/media';
         $config['encrypt_name'] = TRUE;
         $config['allowed_types'] = '*';
         $this->load->library('upload', $config);
         if ($this->upload->do_upload()) {
             $data = array('upload_data' => $this->upload->data());
             $_POST['shipping_lebel'] = $data['upload_data']['file_name'];
         }
         unset($_POST['userfile']);
         unset($_POST['dummy']);
         $_POST = array_map('htmlspecialchars', $_POST);
         $shipping_address = array('shipping_name' => $_POST['shipping_name'], 'shipping_company' => $_POST['shipping_company'], 'shipping_address' => $_POST['shipping_address'], 'shipping_city' => $_POST['shipping_city'], 'shipping_state' => $_POST['shipping_state'], 'shipping_zip' => $_POST['shipping_zip'], 'shipping_country' => $_POST['shipping_country'], 'shipping_phone' => $_POST['shipping_phone'], 'shipping_email' => $_POST['shipping_email'], 'shipping_website' => $_POST['shipping_website']);
         unset($_POST['shipping_name']);
         unset($_POST['shipping_company']);
         unset($_POST['shipping_address']);
         unset($_POST['shipping_city']);
         unset($_POST['shipping_state']);
         unset($_POST['shipping_zip']);
         unset($_POST['shipping_country']);
         unset($_POST['shipping_phone']);
         unset($_POST['shipping_email']);
         unset($_POST['shipping_website']);
         $core_settings = Setting::first();
         $_POST['reference'] = $core_settings->invoice_reference;
         $_POST['project_id'] = '0';
         $_POST['company_id'] = $this->client->company->id;
         $_POST['status'] = 'Sent';
         $_POST['estimate_status'] = 'Sent';
         $_POST['issue_date'] = date('Y-m-d');
         $_POST['due_date'] = date('Y-m-d', strtotime('+7 days'));
         $_POST['currency'] = $core_settings->currency;
         $_POST['terms'] = $core_settings->invoice_terms;
         $_POST['invoice_type'] = $this->invoice_shipment_type;
         $_POST['estimate'] = 1;
         $estimate = Invoice::create($_POST);
         $new_estimate_reference = $_POST['reference'] + 1;
         $estimate_id = $estimate->id;
         $this->projectlib->addInvoiceAddress($estimate_id, true, $shipping_address);
         $estimate_reference = Setting::first();
         $estimate_reference->update_attributes(array('invoice_reference' => $new_estimate_reference));
         if (!$estimate) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_create_estimate_error'));
         } else {
             $this->load->library('userlib');
             $this->load->library('parser');
             $this->load->helper(array('dompdf', 'file'));
             $module_estimate = Module::find_by_link('estimates');
             $admins = $this->userlib->getAdmins($module_estimate->id);
             $admin_list = array_keys($admins);
             $parse_data = array('client_contact' => $estimate->company->client->firstname . ' ' . $estimate->company->client->lastname, 'client_company' => $estimate->company->name, 'estimate_id' => $core_settings->estimate_prefix . $estimate->reference, 'estimate_link' => base_url() . 'estimates/view/32' . $estimate->id, 'company' => $core_settings->company, 'logo' => '<img src="' . base_url() . '' . $core_settings->logo . '" alt="' . $core_settings->company . '"/>', 'invoice_logo' => '<img src="' . base_url() . '' . $core_settings->invoice_logo . '" alt="' . $core_settings->company . '"/>');
             $subject = $this->parser->parse_string($core_settings->estimate_mail_subject, $parse_data);
             $this->email->from($core_settings->email, $core_settings->company);
             $this->email->to($admin_list);
             $this->email->subject($subject);
             $email_estimate = read_file('./application/views/' . $core_settings->template . '/templates/email_admin_estimate.html');
             $message = $this->parser->parse_string($email_estimate, $parse_data);
             $this->email->message($message);
             if ($this->email->send()) {
                 log_message('error', 'Estimate #' . $core_settings->estimate_prefix . $estimate->reference . ' has been send to admins who has access to estimate');
             } else {
                 log_message('error', 'ERROR: Estimate #' . $core_settings->estimate_prefix . $estimate->reference . ' has not been send to admins who has access to estimate. Please check your servers email settings.');
             }
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_create_estimate_success'));
         }
         redirect('cestimates');
     } else {
         $this->load->library('geolib');
         $this->view_data['geolib'] = $this->geolib;
         $this->view_data['shipping_methods'] = ShippingMethod::find('all', array('order' => 'name desc'));
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_create_shipping_estimate');
         $this->view_data['form_action'] = 'cestimates/createShippingEstimate';
         $this->content_view = 'estimates/client_views/_cestimate';
     }
 }
コード例 #2
0
ファイル: estimates.php プロジェクト: imranweb7/msitc-erp
 function updateShippingEstimate($id = FALSE, $getview = FALSE)
 {
     $this->load->helper('notification');
     $this->view_data['submenu'] = array();
     if ($_POST) {
         $estimate = Invoice::find($id);
         unset($_POST['send']);
         unset($_POST['files']);
         $_POST['shipping_lebel'] = $estimate->shipping_lebel;
         $config['upload_path'] = './files/media';
         $config['encrypt_name'] = TRUE;
         $config['allowed_types'] = '*';
         $this->load->library('upload', $config);
         if ($this->upload->do_upload()) {
             $data = array('upload_data' => $this->upload->data());
             $_POST['shipping_lebel'] = $data['upload_data']['file_name'];
         }
         unset($_POST['userfile']);
         unset($_POST['dummy']);
         $_POST = array_map('htmlspecialchars', $_POST);
         $shipping_address = array('shipping_name' => $_POST['shipping_name'], 'shipping_company' => $_POST['shipping_company'], 'shipping_address' => $_POST['shipping_address'], 'shipping_city' => $_POST['shipping_city'], 'shipping_state' => $_POST['shipping_state'], 'shipping_zip' => $_POST['shipping_zip'], 'shipping_country' => $_POST['shipping_country'], 'shipping_phone' => $_POST['shipping_phone'], 'shipping_email' => $_POST['shipping_email'], 'shipping_website' => $_POST['shipping_website']);
         unset($_POST['shipping_name']);
         unset($_POST['shipping_company']);
         unset($_POST['shipping_address']);
         unset($_POST['shipping_city']);
         unset($_POST['shipping_state']);
         unset($_POST['shipping_zip']);
         unset($_POST['shipping_country']);
         unset($_POST['shipping_phone']);
         unset($_POST['shipping_email']);
         unset($_POST['shipping_website']);
         $estimate->update_attributes($_POST);
         $estimate_id = $estimate->id;
         $this->projectlib->updateInvoiceAddress($estimate_id, true, $shipping_address);
         if (!$estimate) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_estimate_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_estimate_success'));
         }
         redirect('estimates/view/' . $id);
     } else {
         $estimate_address = InvoiceHasAddress::find('all', array('conditions' => array('invoice_id=?', $id)));
         if (count($estimate_address)) {
             foreach ($estimate_address as $address) {
                 $this->view_data['address'] = $address;
             }
         }
         $this->view_data['estimate'] = Invoice::find($id);
         $this->load->library('geolib');
         $this->view_data['geolib'] = $this->geolib;
         $this->view_data['shipping_methods'] = ShippingMethod::find('all', array('order' => 'name desc'));
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_edit_shipping_estimate');
         $this->view_data['form_action'] = 'estimates/update/' . $id . '/view';
         $this->content_view = 'estimates/_edit_estimate';
     }
 }
コード例 #3
0
ファイル: cprojects.php プロジェクト: imranweb7/msitc-erp
 function create()
 {
     if ($_POST) {
         unset($_POST['send']);
         unset($_POST['files']);
         $_POST['reference_photo'] = '';
         $config['upload_path'] = './files/media/projects/references/';
         $config['encrypt_name'] = TRUE;
         $config['allowed_types'] = '*';
         $this->load->library('upload', $config);
         if ($this->upload->do_upload()) {
             $data = array('upload_data' => $this->upload->data());
             $_POST['reference_photo'] = $data['upload_data']['file_name'];
         }
         unset($_POST['userfile']);
         unset($_POST['dummy']);
         $_POST['datetime'] = time();
         $_POST['company_id'] = $this->client->company->id;
         $_POST = array_map('htmlspecialchars', $_POST);
         $_POST['phases'] = $this->projectlib->getProjectPhasesByTypeId($_POST['project_type_id']);
         $_POST['media_phases'] = $this->projectlib->getProjectPhasesByTypeId($_POST['project_type_id'], 'media');
         $project = Project::create($_POST);
         $new_project_reference = $_POST['reference'] + 1;
         $project_reference = Setting::first();
         $project_reference->update_attributes(array('project_reference' => $new_project_reference));
         if (!$project) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_create_project_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_create_project_success'));
             //$attributes = array('project_id' => $project->id, 'user_id' => $this->user->id);
             //ProjectHasWorker::create($attributes);
         }
         redirect('cprojects');
     } else {
         $this->view_data['companies'] = Company::find('all', array('conditions' => array('inactive=?', '0')));
         $this->view_data['project_types'] = ProjectType::find('all', array('conditions' => array('inactive=?', '0')));
         $this->view_data['shipping_methods'] = ShippingMethod::find('all', array('conditions' => array('inactive=?', '0')));
         $this->view_data['next_reference'] = Project::last();
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_create_project');
         $this->view_data['form_action'] = 'cprojects/create';
         $this->content_view = 'projects/_cproject';
     }
 }
コード例 #4
0
 function view($id = FALSE)
 {
     $this->view_data['submenu'] = array();
     $this->view_data['shipping_method'] = ShippingMethod::find($id);
     $this->content_view = 'shipping/methods/view';
 }
コード例 #5
0
ファイル: projects.php プロジェクト: imranweb7/msitc-erp
 function item($id = FALSE, $condition = FALSE, $item_id = FALSE)
 {
     $this->load->helper('notification');
     $this->view_data['submenu'] = array($this->lang->line('application_back') => 'projects', $this->lang->line('application_overview') => 'projects/view/' . $id, $this->lang->line('application_tasks') => 'projects/tasks/' . $id, $this->lang->line('application_media') => 'projects/media/' . $id);
     switch ($condition) {
         case 'shippingItemView':
             $this->theme_view = 'modal';
             $this->content_view = 'projects/view_shipping_item';
             $this->view_data['title'] = $this->lang->line('application_shipping_item_details');
             $this->view_data['project'] = Project::find($id);
             $this->view_data['project_id'] = $id;
             $this->view_data['item'] = ProjectHasItem::find($item_id);
             $this->view_data['form_action'] = 'projects/item/' . $id . '/shippingItemView/' . $item_id;
             $this->view_data['backlink'] = 'projects/view/' . $id;
             break;
         case 'view':
             $this->theme_view = 'modal';
             $this->content_view = 'projects/view_item';
             $this->view_data['title'] = $this->lang->line('application_item_details');
             $this->view_data['project'] = Project::find($id);
             $this->view_data['project_id'] = $id;
             $this->view_data['item'] = ProjectHasItem::find($item_id);
             $this->view_data['form_action'] = 'projects/item/' . $id . '/view/' . $item_id;
             $this->view_data['backlink'] = 'projects/view/' . $id;
             break;
         case 'add':
             $this->content_view = 'projects/_item';
             $this->view_data['project'] = Project::find($id);
             if ($_POST) {
                 $is_new_item = false;
                 if (isset($_POST['new_item']) && htmlspecialchars($_POST['new_item']) == "1") {
                     $is_new_item = true;
                     $config['upload_path'] = self::ITEM_UPLOAD_PATH;
                     $config['encrypt_name'] = TRUE;
                     $config['allowed_types'] = '*';
                     $this->load->library('upload', $config);
                     if (!$this->upload->do_upload()) {
                         $error = $this->upload->display_errors('', ' ');
                         $this->session->set_flashdata('message', 'error:' . $error);
                         redirect('projects/item/' . $id);
                     } else {
                         $data = array('upload_data' => $this->upload->data());
                         $filename = $data['upload_data']['orig_name'];
                         $savename = $data['upload_data']['file_name'];
                         $type = $data['upload_data']['file_type'];
                     }
                     unset($_POST['send']);
                     unset($_POST['userfile']);
                     unset($_POST['file-name']);
                     unset($_POST['files']);
                     unset($_POST['new_item']);
                     $_POST = array_map('htmlspecialchars', $_POST);
                     $item_name = $item_description = $_POST['name'];
                     $cost = $original_cost = $_POST['cost'];
                     $sku = $_POST['sku'];
                     $inactive = $_POST['inactive'];
                     $item_data = array('photo' => $savename, 'photo_type' => $type, 'photo_original_name' => $filename, 'name' => $item_name, 'value' => $original_cost, 'description' => $item_description, 'sku' => $sku, 'inactive' => $inactive);
                     $item = Item::create($item_data);
                     $item_id = $_POST['item_id'] = $item->id;
                 } else {
                     unset($_POST['send']);
                     unset($_POST['userfile']);
                     unset($_POST['file-name']);
                     unset($_POST['files']);
                     unset($_POST['new_item']);
                     unset($_POST['name']);
                     unset($_POST['sku']);
                     unset($_POST['inactive']);
                     $_POST = array_map('htmlspecialchars', $_POST);
                     $_POST['project_id'] = $id;
                     $item_id = $_POST['item_id'];
                     $item_details = Item::find($item_id);
                     $item_name = $item_details->name;
                     $item_description = $item_details->description;
                     $cost = empty($_POST['cost']) ? $item_details->value : $_POST['cost'];
                     $original_cost = $item_details->value;
                     $savename = $item_details->photo;
                     $type = $item_details->photo_type;
                     $filename = $item_details->photo_original_name;
                     $sku = $item_details->sku;
                     $inactive = $item_details->inactive;
                 }
                 $project_item_exist = ProjectHasItem::count(array('conditions' => array('project_id=? AND item_id=?', $id, $item_id)));
                 if ($project_item_exist) {
                     $project_item = false;
                     $error = $this->lang->line('messages_project_save_item_exist');
                     $this->session->set_flashdata('message', 'error:' . $error);
                     redirect('projects/view/' . $id);
                 } else {
                     $project_item_data = array('item_id' => $item_id, 'project_id' => $id, 'name' => $item_name, 'cost' => $cost, 'original_cost' => $original_cost, 'photo' => $savename, 'photo_type' => $type, 'photo_original_name' => $filename, 'description' => $item_description, 'sku' => $sku, 'inactive' => $inactive);
                     $project_item = ProjectHasItem::create($project_item_data);
                 }
                 if (!$project_item) {
                     $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_project_save_item_error'));
                 } else {
                     $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_project_save_item_success'));
                     $attributes = array('subject' => $this->lang->line('application_new_project_item_subject'), 'message' => '<b>' . $this->user->firstname . ' ' . $this->user->lastname . '</b> ' . $this->lang->line('application_item_created') . ' ' . $item_name, 'datetime' => time(), 'project_id' => $id, 'type' => 'item', 'user_id' => $this->user->id);
                     $activity = ProjectHasActivity::create($attributes);
                     foreach ($this->view_data['project']->project_has_workers as $workers) {
                         send_notification($workers->user->email, "[" . $this->view_data['project']->name . "] " . $this->lang->line('application_new_project_item_subject'), $this->lang->line('application_new_project_item_was_added') . ' <strong>' . $this->view_data['project']->name . '</strong>');
                     }
                     if (isset($this->view_data['project']->company->client->email)) {
                         $access = explode(',', $this->view_data['project']->company->client->access);
                         if (in_array('12', $access)) {
                             send_notification($this->view_data['project']->company->client->email, "[" . $this->view_data['project']->name . "] " . $this->lang->line('application_new_project_item_subject'), $this->lang->line('application_new_project_item_was_added') . ' <strong>' . $this->view_data['project']->name . '</strong>');
                         }
                     }
                 }
                 redirect('projects/view/' . $id);
             } else {
                 $this->theme_view = 'modal';
                 $this->view_data['items'] = Item::find('all', array('conditions' => array('inactive=?', '0')));
                 $this->view_data['title'] = $this->lang->line('application_add_item');
                 $this->view_data['form_action'] = 'projects/item/' . $id . '/add';
                 $this->content_view = 'projects/_item';
             }
             break;
         case 'addShippingItem':
             $this->content_view = 'projects/_shipping_item';
             $this->view_data['project'] = Project::find($id);
             if ($_POST) {
                 $is_new_item = false;
                 if (isset($_POST['new_item']) && htmlspecialchars($_POST['new_item']) == "1") {
                     $is_new_item = true;
                     unset($_POST['send']);
                     unset($_POST['userfile']);
                     unset($_POST['file-name']);
                     unset($_POST['files']);
                     unset($_POST['new_item']);
                     unset($_POST['item_id']);
                     $_POST = array_map('htmlspecialchars', $_POST);
                     $savename = '';
                     $type = 'shipping';
                     $photo_type = '';
                     $filename = '';
                     $item_name = $item_description = $_POST['name'];
                     $cost = $original_cost = $_POST['value'];
                     $sku = 'shipping#' . time();
                     $inactive = $_POST['inactive'];
                     $shipping_method = $_POST['shipping_method'];
                     $shipping_available_inventory = $_POST['shipping_available_inventory'];
                     $shipping_box_size_length = $_POST['shipping_box_size_length'];
                     $shipping_box_size_width = $_POST['shipping_box_size_width'];
                     $shipping_box_size_height = $_POST['shipping_box_size_height'];
                     $shipping_box_size_weight = $_POST['shipping_box_size_weight'];
                     $shipping_pcs_in_carton = $_POST['shipping_pcs_in_carton'];
                     $item_data = array('description' => $item_description, 'sku' => $sku, 'type' => $type);
                     $item_data = array_merge($item_data, $_POST);
                     $item = Item::create($item_data);
                     $item_id = $_POST['item_id'] = $item->id;
                 } else {
                     unset($_POST['send']);
                     unset($_POST['userfile']);
                     unset($_POST['file-name']);
                     unset($_POST['files']);
                     unset($_POST['new_item']);
                     unset($_POST['name']);
                     unset($_POST['shipping_method']);
                     unset($_POST['shipping_available_inventory']);
                     unset($_POST['shipping_box_size_length']);
                     unset($_POST['shipping_box_size_width']);
                     unset($_POST['shipping_box_size_height']);
                     unset($_POST['shipping_box_size_weight']);
                     unset($_POST['shipping_pcs_in_carton']);
                     $_POST = array_map('htmlspecialchars', $_POST);
                     $_POST['project_id'] = $id;
                     $item_id = $_POST['item_id'];
                     $item_details = Item::find($item_id);
                     $item_name = $item_details->name;
                     $item_description = $item_details->description;
                     $cost = empty($_POST['value']) ? $item_details->value : $_POST['value'];
                     $original_cost = $item_details->value;
                     $savename = $item_details->photo;
                     $type = $item_details->type;
                     $photo_type = $item_details->photo_type;
                     $filename = $item_details->photo_original_name;
                     $sku = $item_details->sku;
                     $inactive = $item_details->inactive;
                     $shipping_method = $item_details->shipping_method;
                     $shipping_available_inventory = $item_details->shipping_available_inventory;
                     $shipping_box_size_length = $item_details->shipping_box_size_length;
                     $shipping_box_size_width = $item_details->shipping_box_size_width;
                     $shipping_box_size_height = $item_details->shipping_box_size_height;
                     $shipping_box_size_weight = $item_details->shipping_box_size_weight;
                     $shipping_pcs_in_carton = $item_details->shipping_pcs_in_carton;
                 }
                 $project_item_exist = ProjectHasItem::count(array('conditions' => array('project_id=? AND item_id=?', $id, $item_id)));
                 if ($project_item_exist) {
                     $project_item = false;
                     $error = $this->lang->line('messages_project_save_shipping_item_exist');
                     $this->session->set_flashdata('message', 'error:' . $error);
                     redirect('projects/view/' . $id);
                 } else {
                     $project_item_data = array('item_id' => $item_id, 'project_id' => $id, 'name' => $item_name, 'cost' => $cost, 'original_cost' => $original_cost, 'type' => $type, 'photo' => $savename, 'photo_type' => $photo_type, 'photo_original_name' => $filename, 'description' => $item_description, 'sku' => $sku, 'inactive' => $inactive, 'shipping_method' => $shipping_method, 'shipping_available_inventory' => $shipping_available_inventory, 'shipping_box_size_length' => $shipping_box_size_length, 'shipping_box_size_width' => $shipping_box_size_width, 'shipping_box_size_height' => $shipping_box_size_height, 'shipping_box_size_weight' => $shipping_box_size_weight, 'shipping_pcs_in_carton' => $shipping_pcs_in_carton);
                     $project_item = ProjectHasItem::create($project_item_data);
                 }
                 if (!$project_item) {
                     $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_project_save_shipping_item_error'));
                 } else {
                     $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_project_save_shipping_item_error'));
                     $attributes = array('subject' => $this->lang->line('application_new_project_shipping_item_subject'), 'message' => '<b>' . $this->user->firstname . ' ' . $this->user->lastname . '</b> ' . $this->lang->line('application_item_created') . ' ' . $item_name, 'datetime' => time(), 'project_id' => $id, 'type' => 'item', 'user_id' => $this->user->id);
                     $activity = ProjectHasActivity::create($attributes);
                     foreach ($this->view_data['project']->project_has_workers as $workers) {
                         send_notification($workers->user->email, "[" . $this->view_data['project']->name . "] " . $this->lang->line('application_new_project_shipping_item_subject'), $this->lang->line('application_new_project_shipping_item_was_added') . ' <strong>' . $this->view_data['project']->name . '</strong>');
                     }
                     if (isset($this->view_data['project']->company->client->email)) {
                         $access = explode(',', $this->view_data['project']->company->client->access);
                         if (in_array('12', $access)) {
                             send_notification($this->view_data['project']->company->client->email, "[" . $this->view_data['project']->name . "] " . $this->lang->line('application_new_project_shipping_item_subject'), $this->lang->line('application_new_project_shipping_item_was_added') . ' <strong>' . $this->view_data['project']->name . '</strong>');
                         }
                     }
                 }
                 redirect('projects/view/' . $id);
             } else {
                 $this->theme_view = 'modal';
                 $this->view_data['shipping_methods'] = ShippingMethod::find('all', array('order' => 'name desc'));
                 $this->view_data['items'] = Item::find('all', array('conditions' => array('inactive=? AND type=?', '0', 'shipping')));
                 $this->view_data['title'] = $this->lang->line('application_add_shipping_item');
                 $this->view_data['form_action'] = 'projects/item/' . $id . '/addShippingItem';
                 $this->content_view = 'projects/_shipping_item';
             }
             break;
         case 'update':
             $this->content_view = 'projects/_edit_item';
             $this->view_data['item'] = ProjectHasItem::find($item_id);
             $this->view_data['items'] = Item::find('all', array('conditions' => array('inactive=?', '0')));
             $this->view_data['project'] = Project::find($id);
             if ($_POST) {
                 unset($_POST['send']);
                 unset($_POST['_wysihtml5_mode']);
                 unset($_POST['files']);
                 $_POST = array_map('htmlspecialchars', $_POST);
                 $item_id = $_POST['id'];
                 $item = ProjectHasItem::find($item_id);
                 $item->update_attributes($_POST);
                 if (!$item) {
                     $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_item_error'));
                 } else {
                     $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_item_success'));
                 }
                 redirect('projects/view/' . $id);
             } else {
                 $this->theme_view = 'modal';
                 $this->view_data['title'] = $this->lang->line('application_edit_item');
                 $this->view_data['form_action'] = 'projects/item/' . $id . '/update/' . $item_id;
                 $this->content_view = 'projects/_edit_item';
             }
             break;
         case 'shippingItemUpdate':
             $this->content_view = 'projects/_edit_shipping_item';
             $this->view_data['item'] = ProjectHasItem::find($item_id);
             $this->view_data['project'] = Project::find($id);
             if ($_POST) {
                 unset($_POST['send']);
                 unset($_POST['_wysihtml5_mode']);
                 unset($_POST['files']);
                 $_POST = array_map('htmlspecialchars', $_POST);
                 $item_id = $_POST['id'];
                 $item = ProjectHasItem::find($item_id);
                 $item->update_attributes($_POST);
                 if (!$item) {
                     $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_shipping_item_error'));
                 } else {
                     $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_shipping_item_success'));
                 }
                 redirect('projects/view/' . $id);
             } else {
                 $this->view_data['shipping_methods'] = ShippingMethod::find('all', array('order' => 'name desc'));
                 $this->theme_view = 'modal';
                 $this->view_data['title'] = $this->lang->line('application_edit_shipping_item');
                 $this->view_data['form_action'] = 'projects/item/' . $id . '/shippingItemUpdate/' . $item_id;
                 $this->content_view = 'projects/_edit_shipping_item';
             }
             break;
         case 'delete':
             $item = ProjectHasItem::find($item_id);
             $item->delete();
             if (!$item) {
                 $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_delete_item_error'));
             } else {
                 @unlink(self::ITEM_UPLOAD_PATH . $item->photo);
                 $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_delete_item_success'));
             }
             redirect('projects/view/' . $id);
             break;
         case 'shippingItemDelete':
             $item = ProjectHasItem::find($item_id);
             $item->delete();
             if (!$item) {
                 $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_delete_shipping_item_error'));
             } else {
                 $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_delete_shipping_item_success'));
             }
             redirect('projects/view/' . $id);
             break;
         default:
             $this->view_data['project'] = Project::find($id);
             $this->content_view = 'projects/view/' . $id;
             break;
     }
 }