/** * */ public function CreateNewOrderFromCommunication() { if ($pn_communication_id = $this->request->getParameter('communication_id', pInteger)) { $t_comm = new ca_commerce_communications($pn_communication_id); if (!$t_comm->getPrimaryKey()) { $this->notification->addNotification(_t('Invalid message'), __NOTIFICATION_TYPE_ERROR__); $this->CustomerInfo(); return; } $t_trans = new ca_commerce_transactions($t_comm->get('transaction_id')); if (!$t_trans->getPrimaryKey()) { $this->notification->addNotification(_t('Message is not associated with a transaction'), __NOTIFICATION_TYPE_ERROR__); $this->CustomerInfo(); return; } $t_user = new ca_users($t_trans->get('user_id')); $this->opt_order->setMode(ACCESS_WRITE); $this->opt_order->set('transaction_id', $t_trans->getPrimaryKey()); if ($t_user->getPrimaryKey()) { $this->opt_order->set('billing_fname', $t_user->get('fname')); $this->opt_order->set('billing_lname', $t_user->get('lname')); $this->opt_order->set('billing_email', $t_user->get('email')); $this->opt_order->set('shipping_fname', $t_user->get('fname')); $this->opt_order->set('shipping_lname', $t_user->get('lname')); $this->opt_order->set('shipping_email', $t_user->get('email')); // Pre-populate order with user's profile address $va_mapping = array('billing_organization' => 'user_profile_organization', 'billing_address1' => 'user_profile_address1', 'billing_address2' => 'user_profile_address2', 'billing_city' => 'user_profile_city', 'billing_zone' => 'user_profile_state', 'billing_postal_code' => 'user_profile_postalcode', 'billing_country' => 'user_profile_country', 'billing_phone' => 'user_profile_phone', 'billing_fax' => 'user_profile_fax', 'shipping_organization' => 'user_profile_organization', 'shipping_address1' => 'user_profile_address1', 'shipping_address2' => 'user_profile_address2', 'shipping_city' => 'user_profile_city', 'shipping_zone' => 'user_profile_state', 'shipping_postal_code' => 'user_profile_postalcode', 'shipping_country' => 'user_profile_country', 'shipping_phone' => 'user_profile_phone', 'shipping_fax' => 'user_profile_fax'); foreach ($va_mapping as $vs_field => $vs_pref) { $this->opt_order->set($vs_field, $t_user->getPreference($vs_pref)); } } $this->opt_order->set('order_type', 'L'); // L=loan $this->opt_order->insert(); $this->request->setParameter('order_id', $this->opt_order->getPrimaryKey()); if (!$this->opt_order->numErrors()) { $this->notification->addNotification(_t('Saved changes'), __NOTIFICATION_TYPE_INFO__); // Add items $t_set = new ca_sets($t_trans->get('set_id')); if ($t_set->getPrimaryKey()) { $va_items = $t_set->getItems(); foreach ($va_items as $va_item_list) { foreach ($va_item_list as $vn_i => $va_item) { if (!is_array($va_item['selected_services'])) { //$va_item['selected_services'] = array('DIGITAL_COPY'); // TODO: make default configurable } foreach ($va_item['selected_services'] as $vs_service) { if ($t_item = $this->opt_order->addItem($va_item['row_id'], array('service' => $vs_service), array('representations_ids' => is_array($va_item['selected_representations']) && sizeof($va_item['selected_representations']) ? $va_item['selected_representations'] : null))) { $t_item->updateFee(); } } } } // Delete originating set if configured to do so if ($this->opo_client_services_config->get('set_disposal_policy') == 'DELETE_WHEN_ORDER_CREATED') { $t_set->setMode(ACCESS_WRITE); $t_set->delete(true); } } } else { $va_errors['general'] = $this->opt_order->errors(); $this->notification->addNotification(_t('Errors occurred: %1', join('; ', $this->opt_order->getErrors())), __NOTIFICATION_TYPE_ERROR__); } $this->view->setVar('errors', $va_errors); } $this->OrderOverview(); }
*/ $t_transaction = $this->getVar('transaction'); $pn_communication_id = $this->getVar('communication_id'); ?> <div id="caClientCommunicationsReply"> <a href="#" class="button" style="float: right;" onclick="jQuery('#caClientCommunicationsMessageDisplay').load('<?php print caNavUrl($this->request, 'client/orders', 'Communications', 'ViewMessage', array('communication_id' => $pn_communication_id)); ?> ');"><?php print _t('Cancel'); ?> ›</a> <?php print caFormTag($this->request, 'SendReply', 'caClientCommunicationsReplyForm'); $t_comm = new ca_commerce_communications($pn_communication_id); $vn_to_user_id = $t_comm->get('from_user_id'); if (!preg_match('!' . _t("Re:") . '!i', $vs_subject = $t_comm->get('subject'))) { $vs_subject = _t("Re:") . ' ' . $vs_subject; } $t_comm->clear(); $t_comm->set('subject', $vs_subject); print "<div class='replyMessageHeader'><span class='replyMessageHeaderHeading'>" . _t('Date') . ':</span> ' . caGetLocalizedDateRange($t = time(), $t) . "</div>"; print "<div class='replyMessageHeader'><span class='replyMessageHeaderHeading'>" . _t('To') . ':</span> ' . caClientServicesGetSenderName(array('from_user_id' => $vn_to_user_id)) . "</div>"; foreach ($t_comm->getFormFields() as $vs_f => $va_info) { switch ($vs_f) { case 'subject': case 'message': case 'transaction_id': print $t_comm->htmlFormElement($vs_f) . "<br/>\n"; break; }
print _t("Compose New Message"); ?> </a> <?php } ?> <h1><?php print _t('Communications'); ?> </h1> <?php print "<div id='caClientOrderCommunicationForm' " . (sizeof($va_messages) ? "style='display:none;'" : "") . ">"; print caFormTag($this->request, 'SaveCommunications', 'caClientCommunicationsReplyForm'); $t_comm = new ca_commerce_communications($va_messages[0]['communication_id']); $vn_to_user_id = $t_transaction->get('user_id'); $vs_subject = $t_comm->get('subject'); if ($vs_subject && !preg_match('!' . _t("Re:") . '!i', $vs_subject)) { $vs_subject = _t("Re:") . ' ' . $vs_subject; } $t_comm->clear(); $t_comm->set('subject', $vs_subject); print "<H2>" . _t("New Message") . "</H2>"; print "<div class='caClientOrderCommunicationFormBg'><div class='formLabel'><b>" . _t('To') . ':</b> ' . caClientServicesGetSenderName(array('from_user_id' => $vn_to_user_id)) . "</div>"; foreach ($t_comm->getFormFields() as $vs_f => $va_info) { switch ($vs_f) { case 'subject': case 'message': case 'transaction_id': print $t_comm->htmlFormElement($vs_f) . "\n"; break; }