From: Iain Patterson Date: Thu, 18 Apr 2013 14:46:26 +0000 (-0400) Subject: Link directly to order from contact view. X-Git-Tag: 2013-04-19~4 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=6618cd51a335fa7413d58606cec3600f8f4a805d;p=readifood.git Link directly to order from contact view. Added a link from the contacts page which will create a new order with the beneficiary selected. --- diff --git a/lib/contact.php b/lib/contact.php index 98340b8..ef8c335 100644 --- a/lib/contact.php +++ b/lib/contact.php @@ -52,7 +52,10 @@ if ($role_string) echo " $role_string"; if ($role & $GLOBALS['ROLE_DONOR']) printf(" Donations", urlencode($contact->getDisplayname()), $contact->getId()); if ($role & $GLOBALS['ROLE_REQUESTER']) printf(" Referred", urlencode($contact->getDisplayname()), $contact->getId()); - if ($role & $GLOBALS['ROLE_BENEFICIARY']) printf(" Orders", urlencode($contact->getDisplayname()), $contact->getId()); + if ($role & $GLOBALS['ROLE_BENEFICIARY']) { + printf(" Orders", urlencode($contact->getDisplayname()), $contact->getId()); + if (get_contact_area($contact)) printf(" Place", urlencode($contact->getDisplayname()), $contact->getId()); + } if (check_admin(1)) { echo " " . $contact->getDeleteLink(); } diff --git a/lib/order.php b/lib/order.php index cb40f63..20e5719 100644 --- a/lib/order.php +++ b/lib/order.php @@ -274,9 +274,15 @@ echo " Beneficiary\n"; echo " \n"; echo "\n"; @@ -372,6 +378,31 @@ echo "\n"; } + function show_contact_order_form($contact) { + if (! check_admin(1)) return; + + $area = get_contact_area($contact); + if (! $area) { + echo "

No valid area for contact!

\n"; + return; + } + + $order = new Order; + $order->setBeneficiaryId($contact->getId()); + + echo "
\n"; + echo "

Place an order:

\n"; + + echo "\n"; + show_order_form($order, $area_id); + + echo "\n"; + echo " \n"; + echo "\n"; + echo "
"; submit("add_order", "Order"); echo "
\n"; + echo "
\n"; + } + function show_add_new_order_form() { if (! check_admin(1)) return; @@ -632,6 +663,15 @@ break; } } + else if ($parameters[0] == "place") { + if ($parameters[1] == "for") { + if ($parameters[2] == "beneficiary") { + if ($parameters[4]) $contact = get_contact_by_id($parameters[4]); + if (! $contact) $contact = get_contact_by_name(urldecode($parameters[3])); + if ($contact) show_contact_order_form($contact); + } + } + } } list($ignored, $id, $args) = parse_parameters($parameters); //echo "

$name($id) " . print_r($args, true) . "

\n";