/** * Delete product * @param integer id of product * @return void */ public function delete($id) { // Check user permission if (user::is_got()) { // Settings $this->set_title(Kohana::lang('eshop.delete_product')); $this->add_breadcrumb(Kohana::lang('eshop.delete_product'), url::current()); if ($_POST) { if (isset($_POST['yes'])) { // clicked on yes = delete $cat = $this->products->get_product_cat($id); $cat = $cat[0]; $status = $this->products->delete_data($id); // Also delte images if deletition was successful if ($status == TRUE) { gallery::delete_images($id, 'products'); } url::redirect('/cat/' . $cat . '/' . cat::get_name($cat)); } else { url::redirect('/product/' . $id . '/' . string::to_url(product::get_name($id))); } } // page $this->template->content = new View('admin/product_delete'); } else { url::redirect('/denied'); } }
function move_forwards() { $current_user =& singleton("current_user"); global $TPL; $status = $this->get_value("status"); $db = new db_alloc(); if ($this->get_value("clientID")) { $c = $this->get_foreign_object("client"); $extra = " for " . $c->get_value("clientName"); $taskDesc[] = ""; } $taskname1 = "Sale " . $this->get_id() . ": raise an invoice" . $extra; $taskname2 = "Sale " . $this->get_id() . ": place an order to the supplier"; $taskname3 = "Sale " . $this->get_id() . ": pay the supplier"; $taskname4 = "Sale " . $this->get_id() . ": deliver the goods / action the work"; $cyberadmin = 59; $taskDesc[] = "Sale items:"; $taskDesc[] = ""; foreach ((array) $this->get_productSaleItems() as $psiID => $psi_row) { $p = new product(); $p->set_id($psi_row["productID"]); $taskDesc[] = " " . page::money($psi_row["sellPriceCurrencyTypeID"], $psi_row["sellPrice"], "%S%mo") . " for " . $psi_row["quantity"] . " x " . $p->get_name(); $hasItems = true; } if (!$hasItems) { return alloc_error("No sale items have been added."); } $amounts = $this->get_amounts(); $taskDesc[] = ""; $taskDesc[] = "Total: " . $amounts["total_sellPrice"]; $taskDesc[] = "Total inc " . config::get_config_item("taxName") . ": " . $amounts["total_sellPrice_plus_gst"]; $taskDesc[] = ""; $taskDesc[] = "Refer to the sale in alloc for up-to-date information:"; $taskDesc[] = config::get_config_item("allocURL") . "sale/productSale.php?productSaleID=" . $this->get_id(); $taskDesc = implode("\n", $taskDesc); if ($status == "edit") { $this->set_value("status", "allocate"); $items = $this->get_productSaleItems(); foreach ($items as $r) { $psi = new productSaleItem(); $psi->set_id($r["productSaleItemID"]); $psi->select(); if (!$db->qr("SELECT transactionID FROM transaction WHERE productSaleItemID = %d", $psi->get_id())) { $psi->create_transactions(); } } } else { if ($status == "allocate") { $this->set_value("status", "admin"); // 1. from salesperson to admin $q = prepare("SELECT * FROM task WHERE projectID = %d AND taskName = '%s'", $cyberadmin, $taskname1); if (config::for_cyber() && !$db->qr($q)) { $task = new task(); $task->set_value("projectID", $cyberadmin); // Cyber Admin Project $task->set_value("taskName", $taskname1); $task->set_value("managerID", $this->get_value("personID")); // salesperson $task->set_value("personID", 67); // Cyber Support people (jane) $task->set_value("priority", 3); $task->set_value("taskTypeID", "Task"); $task->set_value("taskDescription", $taskDesc); $task->set_value("dateTargetStart", date("Y-m-d")); $task->set_value("dateTargetCompletion", date("Y-m-d", date("U") + 60 * 60 * 24 * 7)); $task->save(); $TPL["message_good"][] = "Task created: " . $task->get_id() . " " . $task->get_value("taskName"); $p1 = new person(); $p1->set_id($this->get_value("personID")); $p1->select(); $p2 = new person(); $p2->set_id(67); $p2->select(); $recipients[$p1->get_value("emailAddress")] = array("name" => $p1->get_name(), "addIP" => true, "internal" => true); $recipients[$p2->get_value("emailAddress")] = array("name" => $p2->get_name(), "addIP" => true, "internal" => true); $comment = $p2->get_name() . ",\n\n" . $taskname1 . "\n\n" . $taskDesc; $commentID = comment::add_comment("task", $task->get_id(), $comment, "task", $task->get_id()); $emailRecipients = comment::add_interested_parties($commentID, null, $recipients); // Re-email the comment out, including any attachments if (!comment::send_comment($commentID, $emailRecipients)) { alloc_error("Email failed to send."); } else { $TPL["message_good"][] = "Emailed task comment to " . $p1->get_value("emailAddress") . ", " . $p2->get_value("emailAddress") . "."; } } } else { if ($status == "admin" && $this->have_perm(PERM_APPROVE_PRODUCT_TRANSACTIONS)) { $this->set_value("status", "finished"); if ($_REQUEST["changeTransactionStatus"]) { $rows = $this->get_productSaleItems(); foreach ($rows as $row) { $ids[] = $row["productSaleItemID"]; } if ($ids) { $q = prepare("UPDATE transaction SET status = '%s' WHERE productSaleItemID in (%s)", $_REQUEST["changeTransactionStatus"], $ids); $db = new db_alloc(); $db->query($q); } } // 2. from admin to salesperson $q = prepare("SELECT * FROM task WHERE projectID = %d AND taskName = '%s'", $cyberadmin, $taskname2); if (config::for_cyber() && !$db->qr($q)) { $task = new task(); $task->set_value("projectID", $cyberadmin); // Cyber Admin Project $task->set_value("taskName", $taskname2); $task->set_value("managerID", 67); // Cyber Support people (jane) $task->set_value("personID", $this->get_value("personID")); // salesperson $task->set_value("priority", 3); $task->set_value("taskTypeID", "Task"); $task->set_value("taskDescription", $taskDesc); $task->set_value("dateTargetStart", date("Y-m-d")); $task->set_value("dateTargetCompletion", date("Y-m-d", date("U") + 60 * 60 * 24 * 7)); $task->save(); $q = prepare("SELECT * FROM task WHERE projectID = %d AND taskName = '%s'", $cyberadmin, $taskname1); $rai_row = $db->qr($q); if ($rai_row) { $task->add_pending_tasks($rai_row["taskID"]); } $order_the_hardware_taskID = $task->get_id(); $TPL["message_good"][] = "Task created: " . $task->get_id() . " " . $task->get_value("taskName"); $task->add_notification(3, 1, "Task " . $task->get_id() . " " . $taskname2, "Task status moved from pending to open.", array(array("field" => "metaPersonID", "who" => -2))); } // 3. from salesperson to admin $q = prepare("SELECT * FROM task WHERE projectID = %d AND taskName = '%s'", $cyberadmin, $taskname3); if (config::for_cyber() && !$db->qr($q)) { $task = new task(); $task->set_value("projectID", $cyberadmin); // Cyber Admin Project $task->set_value("taskName", $taskname3); $task->set_value("managerID", $this->get_value("personID")); // salesperson $task->set_value("personID", 67); // Cyber Support people (jane) $task->set_value("priority", 3); $task->set_value("taskTypeID", "Task"); $task->set_value("taskDescription", $taskDesc); $task->set_value("dateTargetStart", date("Y-m-d")); $task->set_value("dateTargetCompletion", date("Y-m-d", date("U") + 60 * 60 * 24 * 7)); $task->save(); $task->add_pending_tasks($order_the_hardware_taskID); $pay_the_supplier_taskID = $task->get_id(); $TPL["message_good"][] = "Task created: " . $task->get_id() . " " . $task->get_value("taskName"); $task->add_notification(3, 1, "Task " . $task->get_id() . " " . $taskname3, "Task status moved from pending to open.", array(array("field" => "metaPersonID", "who" => -2))); } // 4. from admin to salesperson $q = prepare("SELECT * FROM task WHERE projectID = %d AND taskName = '%s'", $cyberadmin, $taskname4); if (config::for_cyber() && !$db->qr($q)) { $task = new task(); $task->set_value("projectID", $cyberadmin); // Cyber Admin Project $task->set_value("taskName", $taskname4); $task->set_value("managerID", 67); // Cyber Support people $task->set_value("personID", $this->get_value("personID")); // salesperson $task->set_value("priority", 3); $task->set_value("taskTypeID", "Task"); $task->set_value("taskDescription", $taskDesc); $task->set_value("dateTargetStart", date("Y-m-d")); $task->set_value("dateTargetCompletion", date("Y-m-d", date("U") + 60 * 60 * 24 * 7)); $task->save(); $task->add_pending_tasks($pay_the_supplier_taskID); $TPL["message_good"][] = "Task created: " . $task->get_id() . " " . $task->get_value("taskName"); $task->add_notification(3, 1, "Task " . $task->get_id() . " " . $taskname4, "Task status moved from pending to open.", array(array("field" => "metaPersonID", "who" => -2))); } } } } }
?> </th><th><?php echo Kohana::lang('eshop.quantity'); ?> </th><th class="align_right"><?php echo Kohana::lang('eshop.price_one'); ?> </th><th class="align_right"><?php echo Kohana::lang('eshop.total'); ?> </th></tr> <?php foreach ($ordered as $row) { ?> <tr> <td><? echo product::get_name($row['product']); ?></td> <td><? echo $row['quantity']; ?></td> <td class="align_right"><? echo product::get_price($row['product']); ?>,- <?php echo Kohana::lang('eshop.currency'); ?> </td> <td class="align_right"><? echo (product::get_price($row['product'])*$row['quantity']); ?>,- <?php echo Kohana::lang('eshop.currency'); ?> </td> </tr> <?php } ?> <tr> <td colspan="3"><?php
include DIR_WS_CLASSES . 'product.php'; $navigation->remove_current_page(); $sproduct = new product((int) $HTTP_GET_VARS['pID']); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?> > <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?> "> <title><?php echo $sproduct->get_name(); ?> </title> <base href="<?php echo ($request_type == 'SSL' ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?> "> <script language="javascript"><!-- var i=0; function resize() { if (navigator.appName == 'Netscape') i=40; if (document.images[0]) window.resizeTo(document.images[0].width +40, document.images[0].height+80); self.focus(); } //--></script> </head>