Пример #1
1
 public function renderForm()
 {
     $this->fields_form = array('legend' => array('title' => $this->l('Return Merchandise Authorization (RMA)'), 'image' => '../img/admin/return.gif'), 'input' => array(array('type' => 'hidden', 'name' => 'id_order'), array('type' => 'hidden', 'name' => 'id_customer'), array('type' => 'text_customer', 'label' => $this->l('Customer'), 'name' => '', 'size' => '', 'required' => false), array('type' => 'text_order', 'label' => $this->l('Order'), 'name' => '', 'size' => '', 'required' => false), array('type' => 'free', 'label' => $this->l('Customer explanation'), 'name' => 'question', 'size' => '', 'required' => false), array('type' => 'select', 'label' => $this->l('Status'), 'name' => 'state', 'required' => false, 'options' => array('query' => OrderReturnState::getOrderReturnStates($this->context->language->id), 'id' => 'id_order_return_state', 'name' => 'name'), 'desc' => $this->l('Merchandise return (RMA) status.')), array('type' => 'list_products', 'label' => $this->l('Products'), 'name' => '', 'size' => '', 'required' => false, 'desc' => $this->l('List of products in return package.')), array('type' => 'pdf_order_return', 'label' => $this->l('Return slip'), 'name' => '', 'size' => '', 'required' => false, 'desc' => $this->l('The link is only available after validation and before the parcel gets delivered.'))), 'submit' => array('title' => $this->l('Save')));
     $order = new Order($this->object->id_order);
     $quantity_displayed = array();
     // Customized products */
     if ($returned_customizations = OrderReturn::getReturnedCustomizedProducts((int) $this->object->id_order)) {
         foreach ($returned_customizations as $returned_customization) {
             $quantity_displayed[(int) $returned_customization['id_order_detail']] = isset($quantity_displayed[(int) $returned_customization['id_order_detail']]) ? $quantity_displayed[(int) $returned_customization['id_order_detail']] + (int) $returned_customization['product_quantity'] : (int) $returned_customization['product_quantity'];
         }
     }
     // Classic products
     $products = OrderReturn::getOrdersReturnProducts($this->object->id, $order);
     // Prepare customer explanation for display
     $this->object->question = '<span class="normal-text">' . nl2br($this->object->question) . '</span>';
     $this->tpl_form_vars = array('customer' => new Customer($this->object->id_customer), 'url_customer' => 'index.php?tab=AdminCustomers&id_customer=' . (int) $this->object->id_customer . '&viewcustomer&token=' . Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $this->context->employee->id), 'text_order' => sprintf($this->l('Order #%1$d from %2$s'), $order->id, Tools::displayDate($order->date_upd)), 'url_order' => 'index.php?tab=AdminOrders&id_order=' . (int) $order->id . '&vieworder&token=' . Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $this->context->employee->id), 'picture_folder' => _THEME_PROD_PIC_DIR_, 'returnedCustomizations' => $returned_customizations, 'customizedDatas' => Product::getAllCustomizedDatas((int) $order->id_cart), 'products' => $products, 'quantityDisplayed' => $quantity_displayed, 'id_order_return' => $this->object->id, 'state_order_return' => $this->object->state);
     return parent::renderForm();
 }
Пример #2
0
    public function displayForm()
    {
        global $currentIndex, $cookie;
        $obj = $this->loadObject(true);
        $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
        $languages = Language::getLanguages();
        echo '
		<script type="text/javascript">
			id_language = Number(' . $defaultLanguage . ');
		</script>
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<input type="hidden" name="id_order" value="' . $obj->id_order . '" />
			<input type="hidden" name="id_customer" value="' . $obj->id_customer . '" />
			<fieldset class="width3"><legend><img src="../img/admin/return.gif" />' . $this->l('Return Merchandise Authorization (RMA)') . '</legend>
				<label>' . $this->l('Customer:') . ' </label>';
        $customer = new Customer(intval($obj->id_customer));
        echo '
				<div class="margin-form">' . $customer->firstname . ' ' . $customer->lastname . '
				<p style="clear: both"><a href="index.php?tab=AdminCustomers&id_customer=' . $customer->id . '&viewcustomer&token=' . Tools::getAdminToken('AdminCustomers' . intval(Tab::getIdFromClassName('AdminCustomers')) . intval($cookie->id_employee)) . '">' . $this->l('View details on customer page') . '</a></p>
				</div>
				<label>' . $this->l('Order:') . ' </label>';
        $order = new Order(intval($obj->id_order));
        echo '		<div class="margin-form">' . $this->l('Order #') . sprintf('%06d', $order->id) . ' ' . $this->l('from') . ' ' . Tools::displayDate($order->date_upd, $order->id_lang) . '
				<p style="clear: both"><a href="index.php?tab=AdminOrders&id_order=' . $order->id . '&vieworder&token=' . Tools::getAdminToken('AdminOrders' . intval(Tab::getIdFromClassName('AdminOrders')) . intval($cookie->id_employee)) . '">' . $this->l('View details on order page') . '</a></p>
				</div>
				<label>' . $this->l('Customer explanation:') . ' </label>
				<div class="margin-form">' . $obj->question . '</div>
				<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" style="float:right; margin-right:120px;"/>
				<label>' . $this->l('Status:') . ' </label>
				<div class="margin-form">
				<select name=\'state\'>';
        $states = OrderReturnState::getOrderReturnStates($cookie->id_lang);
        foreach ($states as $state) {
            echo '<option value="' . $state['id_order_return_state'] . '"' . ($obj->state == $state['id_order_return_state'] ? ' selected="selected"' : '') . '>' . $state['name'] . '</option>';
        }
        echo '	</select>
				<p style="clear: both">' . $this->l('Merchandise return (RMA) status') . '</p>
				</div>';
        if ($obj->state >= 3) {
            echo '	<label>' . $this->l('Slip:') . ' </label>
				<div class="margin-form">' . $this->l('Generate a new slip from the customer order') . '
				<p style="clear: both"><a href="index.php?tab=AdminOrders&id_order=' . $order->id . '&vieworder&token=' . Tools::getAdminToken('AdminOrders' . intval(Tab::getIdFromClassName('AdminOrders')) . intval($cookie->id_employee)) . '#products">' . $this->l('More information on order page') . '</a></p>
				</div>';
        }
        echo '	<label>' . $this->l('Products:') . ' </label>
				<div class="margin-form">';
        echo '<table cellpadding="0" cellspacing="0">
					<tr>
						<td class="col-left">&nbsp;</td>
						<td>
							<table cellspacing="0" cellpadding="0" class="table">
							<tr>
								<th style="width: 100px;">' . $this->l('Reference') . '</th>
								<th>' . $this->l('Product name') . '</th>
								<th>' . $this->l('Quantity') . '</th>
								<th>' . $this->l('Action') . '</th>
							</tr>';
        $order = new Order(intval($obj->id_order));
        $quantityDisplayed = array();
        /* Customized products */
        if ($returnedCustomizations = OrderReturn::getReturnedCustomizedProducts(intval($obj->id_order))) {
            $allCustomizedDatas = Product::getAllCustomizedDatas(intval($order->id_cart));
            foreach ($returnedCustomizations as $returnedCustomization) {
                echo '
					<tr>
						<td>' . $returnedCustomization['reference'] . '</td>
						<td class="center">' . $returnedCustomization['name'] . '</td>
						<td class="center">' . intval($returnedCustomization['product_quantity']) . '</td>
						<td class="center"><a href="' . $currentIndex . '&deleteorder_return_detail&id_order_detail=' . $returnedCustomization['id_order_detail'] . '&id_customization=' . $returnedCustomization['id_customization'] . '&id_order_return=' . $obj->id . '&token=' . $this->token . '"><img src="../img/admin/delete.gif"></a></td>
					</tr>';
                $customizationDatas =& $allCustomizedDatas[intval($returnedCustomization['product_id'])][intval($returnedCustomization['product_attribute_id'])][intval($returnedCustomization['id_customization'])]['datas'];
                foreach ($customizationDatas as $type => $datas) {
                    echo '<tr>
						<td colspan="4">';
                    if ($type == _CUSTOMIZE_FILE_) {
                        $i = 0;
                        echo '<ul style="margin: 4px 0px 4px 0px; padding: 0px; list-style-type: none;">';
                        foreach ($datas as $data) {
                            echo '<li style="display: inline; margin: 2px;">
										<a href="displayImage.php?img=' . $data['value'] . '&name=' . intval($order->id) . '-file' . ++$i . '" target="_blank"><img src="' . _THEME_PROD_PIC_DIR_ . $data['value'] . '_small" alt="" /></a>
									</li>';
                        }
                        echo '</ul>';
                    } elseif ($type == _CUSTOMIZE_TEXTFIELD_) {
                        $i = 0;
                        echo '<ul style="margin: 0px 0px 4px 0px; padding: 0px 0px 0px 6px; list-style-type: none;">';
                        foreach ($datas as $data) {
                            echo '<li>' . $this->l('Text #') . ++$i . $this->l(':') . ' ' . $data['value'] . '</li>';
                        }
                        echo '</ul>';
                    }
                    echo '</td>
						</tr>';
                }
                $quantityDisplayed[intval($returnedCustomization['id_order_detail'])] = isset($quantityDisplayed[intval($returnedCustomization['id_order_detail'])]) ? $quantityDisplayed[intval($returnedCustomization['id_order_detail'])] + intval($returnedCustomization['product_quantity']) : intval($returnedCustomization['product_quantity']);
            }
        }
        /* Classic products */
        $products = OrderReturn::getOrdersReturnProducts($obj->id, $order);
        foreach ($products as $k => $product) {
            if (!isset($quantityDisplayed[intval($product['id_order_detail'])]) or intval($product['product_quantity']) > intval($quantityDisplayed[intval($product['id_order_detail'])])) {
                echo '
					<tr>
						<td>' . $product['product_reference'] . '</td>
						<td class="center">' . $product['product_name'] . '</td>
						<td class="center">' . $product['product_quantity'] . '</td>
						<td class="center"><a href="' . $currentIndex . '&deleteorder_return_detail&id_order_detail=' . $product['id_order_detail'] . '&id_order_return=' . $obj->id . '&token=' . $this->token . '"><img src="../img/admin/delete.gif"></a></td>
					</tr>';
            }
        }
        echo '
							</table>
						</td>
					</tr>
				</table>
				<p>' . $this->l('List of products in return package') . '</p>
				</div>
				<div class="margin-form">
					
				</div>
			</fieldset>
		</form>';
    }