function display_form_add_product() { global $VM_LANG, $vmLogger; require_once CLASSPATH . 'ps_product_attribute.php'; //require_once(CLASSPATH . 'ps_product.php'); $ps_product_attribute = new ps_product_attribute(); //$ps_product = new ps_product; $order_item_id = vmGet($_REQUEST, 'order_item_id'); // Affichage de l'en-t�te $html_entete = '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; $html_entete .= '<br /><br /><table class="adminlist"><tr><th>' . $VM_LANG->_('VM_ORDER_EDIT_ADD_PRODUCT') . '</th></tr></table>'; $html_entete .= '<table class="adminlist"><tr>'; $html_entete .= '<th>' . $VM_LANG->_('PHPSHOP_ORDER_PRINT_NAME') . '</th>'; $html_pied = '<input type="hidden" name="add_product" value="1" /> <input type="hidden" name="order_edit_page" value="1" /> <input type="hidden" name="page" value="order.order_print" /> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="func" value="" /> <input type="hidden" name="order_id" value="' . $this->order_id . '" /></form>'; $html_return_parent = '<form method="post" action="' . $_SERVER['PHP_SELF'] . '"> <input type="submit" value="' . $VM_LANG->_('VM_ORDER_EDIT_RETURN_PARENTS') . '" /> <input type="hidden" name="product_id" value="-1" /> <input type="hidden" name="add_product_validate" value="0" /> <input type="hidden" name="add_product_item" value="0" /> <input type="hidden" name="add_product" value="1" /> <input type="hidden" name="order_edit_page" value="1" /> <input type="hidden" name="page" value="order.order_print" /> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="func" value="" /> <input type="hidden" name="order_id" value="' . $this->order_id . '" /></form>'; $product_id = vmGet($_REQUEST, 'product_id'); if ($this->product_added == true) { $product_id = -1; } $d = $_REQUEST; $add_product_validate = vmGet($_REQUEST, 'add_product_validate'); if ($product_id < 0 || $product_id == "") { $html_table = '<tr><td>' . $this->list_products($product_id) . '</td>'; $html_entete .= '</tr>'; $html_table .= '</tr></table><input type="hidden" name="add_product_validate" value="0" />'; echo $html_entete . $html_table . $html_pied; return; } $db = new ps_DB(); $q = "SELECT product_id FROM #__{vm}_product WHERE "; $q .= "product_parent_id = '" . $product_id . "'"; $db->query($q); $item = false; // Elements fils s�lectionn�s if (vmGet($_REQUEST, 'add_product_item') == 1) { $item = true; $html_table = '<tr><td>' . $this->list_attribute($product_id, false) . '<input type="hidden" name="add_product_item" value="1" /></td>'; } else { if ($db->num_rows()) { $html_entete .= '</tr>'; $html_table = '<tr><td>' . $this->list_attribute($product_id) . '<input type="hidden" name="add_product_validate" value="0" /><input type="hidden" name="add_product_item" value="1" /></td></tr></table>'; echo $html_entete . $html_table . $html_pied . $html_return_parent; return; } else { $html_table = '<tr><td>' . $this->list_products($product_id) . '</td>'; } } $html_entete .= '<th>' . $VM_LANG->_('PHPSHOP_PRODUCT_FORM_CUSTOM_ATTRIBUTE_LIST') . '</th>'; $html_entete .= '<th>' . $VM_LANG->_('PHPSHOP_PRODUCT_FORM_ATTRIBUTE_LIST') . '</th>'; $html_entete .= '<th align="left">' . $VM_LANG->_('PHPSHOP_ORDER_PRINT_QUANTITY') . '</th>'; $html_entete .= '<th align="left">Action</th></tr>'; $html_table .= '<td>' . $ps_product_attribute->list_advanced_attribute($product_id) . '</td>'; $html_table .= '<td>' . $ps_product_attribute->list_custom_attribute($product_id) . '</td>'; $html_table .= '<td><input type="text" value="1" name="product_quantity" size="5" /><input type="hidden" name="add_product_validate" value="1" /></td>'; $html_table .= '<td><input type="submit" value="' . $VM_LANG->_('VM_ORDER_EDIT_ADD') . '" /></td></tr></table>'; if ($item) { $html_pied .= $html_return_parent; } echo $html_entete . $html_table . $html_pied; return; }
function html_change_add_item() { global $VM_LANG, $vmLogger; require_once CLASSPATH . 'ps_product_attribute.php'; $ps_product_attribute = new ps_product_attribute(); // Get product_id $product_id = vmGet($_REQUEST, 'product_id'); $product_id_bysku = vmGet($_REQUEST, 'product_id_bysku'); // If sku was selected it overwrites the product_id if ($product_id_bysku > 0) { $product_id = $product_id_bysku; } // Output to generate a "return to parant"-button $html_return_parent = '<form method="post" action="' . $_SERVER['PHP_SELF'] . '"> <input type="submit" value="' . $VM_LANG->_('PHPSHOP_ORDER_EDIT_RETURN_PARENTS') . '" /> <input type="hidden" name="product_id" value="-1" /> <input type="hidden" name="add_product_validate" value="0" /> <input type="hidden" name="add_product_item" value="0" /> <input type="hidden" name="add_product" value="1" /> <input type="hidden" name="order_edit_page" value="1" /> <input type="hidden" name="page" value="order.order_print" /> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="func" value="" /> <input type="hidden" name="order_id" value="' . $this->order_id . '" /></form>'; // Page reseted = -1 or called first time = "" if ($product_id < 0 || $product_id == "") { // Generate product list ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <br /><br /> <table class="adminlist"> <tr> <th> <?php echo $VM_LANG->_('PHPSHOP_ORDER_EDIT_ADD_PRODUCT'); ?> </th> </tr> <tr> <td align="left"><?php echo $this->list_products($product_id, true); echo $this->list_products($product_id); ?> </td> </tr> </table> <input type="hidden" name="add_product_validate" value="0" /> <input type="hidden" name="add_product_item" value="0" /> <input type="hidden" name="add_product" value="1" /> <input type="hidden" name="page" value="order.order_print" /> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="func" value="" /> <input type="hidden" name="order_id" value="<?php echo $this->order_id; ?> " /> </form> <?php } else { // Query child products $db = new ps_DB(); $q = "SELECT product_id FROM #__{vm}_product WHERE "; $q .= "product_parent_id = '" . $product_id . "'"; $db->query($q); // Are there childs? if ($db->num_rows()) { // Yes! Drop down list to select the child ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <br /><br /> <table class="adminlist"> <tr> <th><?php echo $VM_LANG->_('PHPSHOP_ORDER_EDIT_ADD_PRODUCT'); ?> </th> </tr> </table> <table class="adminlist"> <tr> <th><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_NAME'); ?> </th> </tr> <tr> <td> <input type="hidden" name="add_product" value="1" /> <input type="hidden" name="add_product_validate" value="0" /> <input type="hidden" name="add_product_item" value="1" /> <?php echo $this->list_attribute($product_id); ?> </td> </tr> </table> <input type="hidden" name="page" value="order.order_print" /> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="func" value="" /> <input type="hidden" name="order_id" value="<?php echo $this->order_id; ?> " /> </form> <?php echo $html_return_parent; } else { // No Childs or selected child product! Form to add a product that has no childs ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <br /><br /> <table class="adminlist"> <tr> <th><?php echo $VM_LANG->_('PHPSHOP_ORDER_EDIT_ADD_PRODUCT'); ?> </th> </tr> </table> <table class="adminlist"> <tr> <th><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_NAME'); ?> </th> <th><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_FORM_CUSTOM_ATTRIBUTE_LIST'); ?> </th> <th><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_FORM_ATTRIBUTE_LIST'); ?> </th> <th align="left"><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_QUANTITY'); ?> </th> <th align="left">Action</th> </tr> <tr> <?php if (vmGet($_REQUEST, 'add_product_item') == 1) { echo '<td>' . $this->list_attribute($product_id, false) . '</td>'; echo '<input type="hidden" name="add_product_item" value="1" />'; } else { echo '<td>' . $this->list_products($product_id, true) . $this->list_products($product_id) . '</td>'; } ?> <td><?php echo $ps_product_attribute->list_advanced_attribute($product_id); ?> </td> <td><?php echo $ps_product_attribute->list_custom_attribute($product_id); ?> </td> <td> <input type="text" value="1" name="product_quantity" size="5" /> <input type="hidden" name="add_product_validate" value="1" /> <input type="hidden" name="add_product" value="1" /> </td> <td><input type="submit" value="<?php echo $VM_LANG->_('PHPSHOP_ORDER_EDIT_ADD'); ?> " /></td> </tr> </table> <input type="hidden" name="page" value="order.order_print" /> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="func" value="" /> <input type="hidden" name="order_id" value="<?php echo $this->order_id; ?> " /> </form> <?php if (vmGet($_REQUEST, 'add_product_item') == 1) { echo $html_return_parent; } } } return; }