/** * @group shopobjects */ function testCreateCompleteShippingMethod() { // GIVEN $shippingMethodParameter = $this->givenCompleteShippingMethod(); // WHEN $shippingMethod = new ShippingMethod($shippingMethodParameter); // THEN echo $shippingMethod->errorNumber(); $this->assertFalse($shippingMethod->error()); $this->assertEquals($shippingMethod->getName(), "DHL"); $this->assertEquals($shippingMethod->getID(), "123456789"); }
public function setShippingMethod(ShippingMethod $option) { $package = $this->owner->createShippingPackage(); if (!$package) { return $this->error(_t("OrderShippingExtension.NoPackage", "Shipping package information not available")); } $address = $this->owner->getShippingAddress(); if (!$address || !$address->exists()) { return $this->error(_t("OrderShippingExtension.NoAddress", "No address has been set")); } $this->owner->ShippingTotal = $option->calculateRate($package, $address); $this->owner->ShippingMethodID = $option->ID; $this->owner->write(); return true; }
/** * @param \SimpleXMLElement $xml * * @return Response */ public function fromXml(\SimpleXMLElement $xml) { foreach ($xml->RatedShipment as $ratedShipment) { $this->addShippingMethod(ShippingMethod::fromXml($ratedShipment)); } return $this; }
public function run() { //$faker = Faker::create(); //foreach(range(1, 10) as $index) //{ ShippingMethod::create(['name' => '货到付款', 'content' => '货到付款']); //} }
public function getCMSFields() { $fields = parent::getCMSFields(); $fieldList = array("Country" => "Country", "State" => "State", "City" => "City", "PostalCode" => "PostCode", "WeightMin" => "WeightMin", "WeightMax" => "WeightMax", "VolumeMin" => "VolumeMin", "VolumeMax" => "VolumeMax", "ValueMin" => "ValueMin", "ValueMax" => "ValueMax", "QuantityMin" => "QuantityMin", "QuantityMax" => "QuantityMax", "Rate" => "Rate"); $fields->fieldByName('Root')->removeByName("Rates"); if ($this->isInDB()) { $tablefield = new GridField("Rates", "TableShippingRate", $this->Rates(), new GridFieldConfig_RecordEditor()); $fields->addFieldToTab("Root.Main", $tablefield); } return $fields; }
public function insert() { $input = Input::all(); $item = ShippingMethod::create($input); return Response::json($item); //$validation = Validator::make($input, User::$rules); //if ($validation->passes()) { // User::create($input); // return Redirect::route('users.index'); //} }
public function setData(Order $order, array $data) { $option = null; if (isset($data['ShippingMethodID'])) { $option = ShippingMethod::get()->byID((int) $data['ShippingMethodID']); } //assign option to order / modifier if ($option) { $order->setShippingMethod($option); Session::set("Checkout.ShippingMethod", $option); } }
public function getCMSFields() { $fields = parent::getCMSFields(); $displayFieldsList = array("ZoneID" => "Zone", "WeightMin" => "WeightMin", "WeightMax" => "WeightMax", "VolumeMin" => "VolumeMin", "VolumeMax" => "VolumeMax", "ValueMin" => "ValueMin", "ValueMax" => "ValueMax", "QuantityMin" => "QuantityMin", "QuantityMax" => "QuantityMax", "Rate" => "Rate"); $fields->fieldByName('Root')->removeByName("Rates"); if ($this->isInDB()) { $gridField = new GridField("Rates", "ZonedShippingRate", $this->Rates(), new GridFieldConfig_RelationEditor()); $gridField->getConfig()->getComponentByType('GridFieldDataColumns')->setDisplayFields($displayFieldsList); $fields->addFieldToTab("Root.Main", $gridField); } return $fields; }
function getCMSFields() { $fields = parent::getCMSFields(); $fieldList = array("Country" => "Country", "State" => "State", "City" => "City", "PostalCode" => "PostCode", "WeightMin" => "WeightMin", "WeightMax" => "WeightMax", "VolumeMin" => "VolumeMin", "VolumeMax" => "VolumeMax", "ValueMin" => "ValueMin", "ValueMax" => "ValueMax", "QuantityMin" => "QuantityMin", "QuantityMax" => "QuantityMax", "Rate" => "Rate"); $fieldTypes = array_merge(RegionRestriction::get_table_field_types(), array("WeightMin" => "TextField", "WeightMax" => "TextField", "VolumeMin" => "TextField", "VolumeMax" => "TextField", "ValueMin" => "TextField", "ValueMax" => "TextField", "QuantityMin" => "TextField", "QuantityMax" => "TextField", "Rate" => "TextField")); $fields->fieldByName('Root')->removeByName("Rates"); if ($this->isInDB()) { $tablefield = new TableField("Rates", "TableShippingRate", $fieldList, $fieldTypes); $tablefield->setCustomSourceItems($this->Rates()); $fields->addFieldToTab("Root.Main", $tablefield); } return $fields; }
function getCMSFields() { $fields = parent::getCMSFields(); $fieldList = array("ZoneID" => "Zone", "WeightMin" => "WeightMin", "WeightMax" => "WeightMax", "VolumeMin" => "VolumeMin", "VolumeMax" => "VolumeMax", "ValueMin" => "ValueMin", "ValueMax" => "ValueMax", "QuantityMin" => "QuantityMin", "QuantityMax" => "QuantityMax", "Rate" => "Rate"); $fieldTypes = array("ZoneID" => "ZoneSelectField", "WeightMin" => "TextField", "WeightMax" => "TextField", "VolumeMin" => "TextField", "VolumeMax" => "TextField", "ValueMin" => "TextField", "ValueMax" => "TextField", "QuantityMin" => "TextField", "QuantityMax" => "TextField", "Rate" => "TextField"); $fields->fieldByName('Root')->removeByName("Rates"); if ($this->isInDB()) { $tablefield = new TableField("Rates", "ZonedShippingRate", $fieldList, $fieldTypes); $tablefield->setCustomSourceItems($this->Rates()); $fields->addFieldToTab("Root.Main", $tablefield); } return $fields; }
function setShippingMethod($data, $form) { $order = $this->owner->Cart(); $option = null; if (isset($data['ShippingMethodID'])) { $option = ShippingMethod::get()->byID((int) $data['ShippingMethodID']); } //assign option to order / modifier if ($option) { $order->setShippingMethod($option); } $this->owner->redirect($this->NextStepLink()); }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->fieldByName('Root')->removeByName("DistanceFares"); if ($this->isInDB()) { $fields->addFieldToTab("Root.Main", $gridfield = GridField::create("DistanceFares", "Fares", $this->DistanceFares(), $config = new GridFieldConfig_RecordEditor())); $config->removeComponentsByType("GridFieldDataColumns"); $config->removeComponentsByType("GridFieldEditButton"); $config->removeComponentsByType("GridFieldDeleteAction"); $config->removeComponentsByType("GridFieldAddNewButton"); $config->addComponent($cols = new GridFieldEditableColumns()); $config->addComponent(new GridFieldDeleteAction()); $config->addComponent($addnew = new GridFieldAddNewInlineButton()); $addnew->setTitle($addnew->getTitle() . " Fare"); if ($greatest = $this->greatestCostDistance()) { $fields->insertAfter(LiteralField::create("costnote", "<p class=\"message\">Distances beyond the greatest specified distance will be cost " . $this->greatestCostDistance()->dbObject("Cost")->Nice() . " (the most expensive fare)</p>"), "DistanceFares"); } } return $fields; }
/** * 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 = ShippingMethod::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public static function getShippingMethod($costs = false) { if ($shipping_method = Yii::app()->user->getState('shipping_method')) { $weight_total = Shop::getWeightTotal(); $methods = ShippingMethod::model()->findAll('id = :id', array(':id' => $shipping_method)); foreach ($methods as $method) { $range = explode('-', $method->weight_range); if (isset($range[0]) && isset($range[1]) && is_numeric($range[0]) && is_numeric($range[1])) { if ($range[0] <= $weight_total && $range[1] >= $weight_total) { if ($costs) { return Shop::priceFormat($method->getPrice()); } else { return $method; } } } } } }
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'; } }
</div> </fieldset> <br /> <hr /> <h3> <?php echo Shop::t('Shipping Method'); ?> </h3> <p> <?php echo Shop::t('Choose your Shipping method'); ?> </p> <?php $i = 0; foreach (ShippingMethod::model()->findAll() as $method) { echo '<div class="row">'; echo CHtml::radioButton("ShippingMethod", $i == 0, array('value' => $method->id)); echo '<div class="float-left">'; echo CHtml::label($method->title, 'ShippingMethod'); echo CHtml::tag('p', array(), $method->description); echo CHtml::tag('p', array(), Shop::t('Price: ') . Shop::priceFormat($method->price)); echo '</div>'; echo '</div>'; echo '<div class="clear"></div>'; $i++; } ?>
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; } }
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'; } }
/** * get options that apply to package and location */ function getShippingMethods() { //TODO: restrict options to region / package specs return ShippingMethod::get()->filter("Enabled", 1); }
Shop::renderFlash(); echo CHtml::beginForm(array('//shop/order/confirm')); echo '<h2>' . Shop::t('Confirmation') . '</h2>'; if (Shop::getCartContent() == array()) { return false; } // If the customer is not passed over to the view, we assume the user is // logged in and we fetch the customer data from the customer table if (!isset($customer)) { $customer = Shop::getCustomer(); } $this->renderPartial('application.modules.shop.views.customer.view', array('model' => $customer, 'hideAddress' => true, 'hideEmail' => true)); echo '<br />'; echo '<hr />'; echo '<p>'; $shipping = ShippingMethod::model()->find('id = :id', array(':id' => Yii::app()->user->getState('shipping_method'))); echo '<strong>' . Shop::t('Shipping Method') . ': </strong>' . ' ' . $shipping->title . ' (' . $shipping->description . ')'; echo '<br />'; echo CHtml::link(Shop::t('Edit shipping method'), array('//shop/shippingMethod/choose', 'order' => true)); echo '</p>'; echo '<p>'; $payment = PaymentMethod::model()->findByPk(Yii::app()->user->getState('payment_method')); echo '<strong>' . Shop::t('Payment method') . ': </strong>' . ' ' . $payment->title . ' (' . $payment->description . ')'; echo '<br />'; echo CHtml::link(Shop::t('Edit payment method'), array('//shop/paymentMethod/choose', 'order' => true)); echo '</p>'; echo '<hr />'; $this->renderPartial('application.modules.shop.views.shoppingCart.view'); echo '<h3>' . Shop::t('Please add additional comments to the order here') . '</h3>'; echo CHtml::textArea('Order[Comment]', @Yii::app()->user->getState('order_comment'), array('class' => 'order_comment')); echo '<br /><br />';
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'; } }
function view($id = FALSE) { $this->view_data['submenu'] = array(); $this->view_data['shipping_method'] = ShippingMethod::find($id); $this->content_view = 'shipping/methods/view'; }
public static function getShippingMethod() { if ($shipping_method = Yii::app()->user->getState('shipping_method')) { return ShippingMethod::model()->findByPk($shipping_method); } }
<?php $this->widget('bootstrap.widgets.TbAlert'); ?> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('shipping_firstname', 'shipping_lastname', 'shipping_company', 'shipping_address_1', 'shipping_address_2', 'shipping_city', 'shipping_postcode', 'shipping_country', 'shipping_zone', 'shipping_address_format', array('label' => 'Shipping Method', 'type' => 'raw', 'value' => ShippingMethod::model()->findByPk($model->shipping_method)->getName()), 'shipping_code')));
/** Creation of a new Order * Before we create a new order, we need to gather Customer information. * If the user is logged in, we check if we already have customer information. * If so, we go directly to the Order confirmation page with the data passed * over. Otherwise we need the user to enter his data, and depending on * whether he is logged in into the system it is saved with his user * account or once just for this order. */ public function actionCreate($customer = null, $payment_method = null, $shipping_method = null) { // Shopping cart is empty, taking a order is not allowed yet if (Shop::getCartContent() == array()) { $this->redirect(array('//shop/shoppingCart/view')); } if (isset($_POST['ShippingMethod'])) { Yii::app()->user->setState('shipping_method', $_POST['ShippingMethod']); } if (isset($_POST['PaymentMethod'])) { Yii::app()->user->setState('payment_method', $_POST['PaymentMethod']); } if (isset($_POST['DeliveryAddress']) && @$_POST['toggle_delivery'] == true) { if (Address::isEmpty($_POST['DeliveryAddress'])) { Shop::setFlash(Shop::t('Delivery address is not complete! Please fill in all fields to set the Delivery address')); } else { $deliveryAddress = new DeliveryAddress(); $deliveryAddress->attributes = $_POST['DeliveryAddress']; if ($deliveryAddress->save()) { $model = Shop::getCustomer(); if (isset($_POST['toggle_delivery'])) { $model->delivery_address_id = $deliveryAddress->id; } else { $model->delivery_address_id = 0; } $model->save(false, array('delivery_address_id')); } } } if (isset($_POST['BillingAddress']) && @$_POST['toggle_billing'] == true) { if (Address::isEmpty($_POST['BillingAddress'])) { Shop::setFlash(Shop::t('Billing address is not complete! Please fill in all fields to set the Billing address')); } else { $BillingAddress = new BillingAddress(); $BillingAddress->attributes = $_POST['BillingAddress']; if ($BillingAddress->save()) { $model = Shop::getCustomer(); if (isset($_POST['toggle_billing'])) { $model->billing_address_id = $BillingAddress->id; } else { $model->billing_address_id = 0; } $model->save(false, array('billing_address_id')); } } } if (!$customer) { $customer = Yii::app()->user->getState('customer_id'); } if (!Yii::app()->user->isGuest && !$customer) { $customer = Customer::model()->find('user_id = :user_id ', array(':user_id' => Yii::app()->user->id)); } if (!$payment_method) { $payment_method = Yii::app()->user->getState('payment_method'); } if (!$shipping_method) { $shipping_method = Yii::app()->user->getState('shipping_method'); } if (!$customer) { $this->render('/customer/create', array('action' => array('//shop/customer/create'))); Yii::app()->end(); } if (!$shipping_method) { $this->render('/shippingMethod/choose', array('customer' => Shop::getCustomer())); Yii::app()->end(); } if (!$payment_method) { $this->render('/paymentMethod/choose', array('customer' => Shop::getCustomer())); Yii::app()->end(); } if ($customer && $payment_method && $shipping_method) { if (is_numeric($customer)) { $customer = Customer::model()->findByPk($customer); } if (is_numeric($shipping_method)) { $shipping_method = ShippingMethod::model()->find('id = :id', array(':id' => $shipping_method)); } if (is_numeric($payment_method)) { $payment_method = PaymentMethod::model()->findByPk($payment_method); } $this->render('/order/create', array('customer' => $customer, 'shippingMethod' => $shipping_method, 'paymentMethod' => $payment_method)); } }
?> <?php echo $form->dropDownList($model, 'payment_method', CHtml::listData(PaymentMethod::model()->findAll(), 'id', function ($data) { return $data->getName(); })); ?> <?php echo $form->error($model, 'payment_method'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'shipping_method'); ?> <?php echo $form->dropDownList($model, 'shipping_method', CHtml::listData(ShippingMethod::model()->findAll(), 'id', function ($data) { return $data->getName(); })); ?> <?php echo $form->error($model, 'shipping_method'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'order_status_id'); ?> <?php echo $form->dropDownList($model, 'order_status_id', CHtml::listData(OrderStatus::model()->findAll(), 'id', function ($data) { return $data->getName(); }));
<?php $methods = ShippingMethod::model()->findAll(); printf('<h2>%s</h2>', Shop::t('Available shipping methods')); if ($methods) { echo '<table>'; foreach ($methods as $method) { printf('<tr><td>%s</td><td>%s</td></tr>', $method->description, Shop::priceFormat($method->price)); } echo '</table>'; }
</table> <div class='row'> <div class="order-checkout-memo"> <div class="col-span-10 checkout-memo text-left"> <h3>给卖家留言:</h3> <?php echo CHtml::textArea('memo', '', array('placeholder' => '选填,可以告诉卖家您对商品的特殊要求,如:颜色、尺码等', 'class' => '')); ?> </div> <div class="col-span-2 express text-left"> <h3>配送方式:</h3> <span class="select-wrapper"> <?php $cri = new CDbCriteria(array('condition' => 'enabled = 1')); $shippingMethod = ShippingMethod::model()->findAll($cri); $list = CHtml::listData($shippingMethod, 'id', 'name'); echo CHtml::dropDownList('ship_method', '', $list); ?> <!-- <select> <option value="classic" selected="">Classic</option> <option value="classically">Classically</option> <option value="classicalest">Classicalest</option> </select>--> </span> </div> </div> </div> <div class="clearfix"></div> <div class="order-confirm text-right" style='margin-top:10px'><?php
public function loadModel($id, $weight_range = null) { if ($weight_range) { $model = ShippingMethod::model()->find('id = :id and weight_range = :weight_range', array(':id' => $id, ':weight_range' => $weight_range)); } else { $model = ShippingMethod::model()->find('id = :id', array(':id' => $id)); } if ($model === null) { throw new CHttpException(404, 'The requested shipping Method does not exist.'); } return $model; }
Shop::renderFlash(); echo CHtml::beginForm(array('//shop/order/confirm')); echo '<h2>' . Shop::t('Confirmation') . '</h2>'; if (Shop::getCartContent() == array()) { return false; } // If the customer is not passed over to the view, we assume the user is // logged in and we fetch the customer data from the customer table if (!isset($customer)) { $customer = Shop::getCustomer(); } $this->renderPartial('application.modules.shop.views.customer.view', array('model' => $customer, 'hideAddress' => true, 'hideEmail' => true)); echo '<br />'; echo '<hr />'; echo '<p>'; $shipping = ShippingMethod::model()->findByPk(Yii::app()->user->getState('shipping_method')); echo '<strong>' . Shop::t('Shipping Method') . ': </strong>' . ' ' . $shipping->title . ' (' . $shipping->description . ')'; echo '<br />'; echo CHtml::link(Shop::t('Edit shipping method'), array('//shop/shippingMethod/choose', 'order' => true)); echo '</p>'; echo '<p>'; $payment = PaymentMethod::model()->findByPk(Yii::app()->user->getState('payment_method')); echo '<strong>' . Shop::t('Payment method') . ': </strong>' . ' ' . $payment->title . ' (' . $payment->description . ')'; echo '<br />'; echo CHtml::link(Shop::t('Edit payment method'), array('//shop/paymentMethod/choose', 'order' => true)); echo '</p>'; echo '<hr />'; $this->renderPartial('application.modules.shop.views.shoppingCart.view'); echo '<h3>' . Shop::t('Please add additional comments to the order here') . '</h3>'; echo CHtml::textArea('Order[Comment]', @Yii::app()->user->getState('order_comment'), array('style' => 'width:600px; height:100px;padding:10px;')); echo '<br /><br />';