* ---------------------------------------------------------------------- */ $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;
caUI.initUtils(); </script> </head> <body> <div id="topBar"> <?php print join(" ", $this->getVar('nav')->getHTMLMenuBarAsLinkArray()); $vb_client_services = (bool) $this->request->config->get('enable_client_services'); if (!$this->request->config->get('dont_allow_registration_and_login')) { if ($this->request->isLoggedIn()) { $o_client_services_config = caGetClientServicesConfiguration(); if ($vb_client_services && (bool) $o_client_services_config->get('enable_user_communication')) { // // Unread client communications // $t_comm = new ca_commerce_communications(); $va_unread_messages = $t_comm->getMessages(array('unreadOnly' => true, 'user_id' => $this->request->getUserID())); $va_message_set_ids = array(); foreach ($va_unread_messages as $vn_transaction_id => $va_messages) { $va_message_set_ids[] = $va_messages[0]['set_id']; } } if (!$this->request->config->get('disable_my_collections')) { # --- get all sets for user $t_set = new ca_sets(); $va_sets = caExtractValuesByUserLocale($t_set->getSets(array('table' => 'ca_objects', 'user_id' => $this->request->getUserID()))); if (is_array($va_sets) && sizeof($va_sets) > 1) { print "<div id='lightboxLink'>\n\t\t\t\t\t\t\t\t\t\t<a href='#' onclick='\$(\"#lightboxList\").toggle(0, function(){\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(\$(\"#lightboxLink\").hasClass(\"lightboxLinkActive\")) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\$(\"#lightboxLink\").removeClass(\"lightboxLinkActive\");\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\$(\"#lightboxLink\").addClass(\"lightboxLinkActive\");\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t});')>Lightbox</a>"; if (is_array($va_message_set_ids) && sizeof($va_message_set_ids)) { print " <img src='" . $this->request->getThemeUrlPath() . "/graphics/icons/envelope.gif' border='0'>"; }
?> ›</a> <H1><?php print _t("Contact Support"); ?> </H1> <div class="bg"> <div id="messageForm"> <div class="intro"> <?php print _t('Use the message box below to inquire about your order:'); ?> </div><!-- end intro --> <?php print caFormTag($this->request, 'SendReply', 'caClientCommunicationsReplyFormMyAccount', null, 'post', 'application/x-www-form-urlencoded', '_top', array('disableUnsavedChangesWarning' => true)); $t_comm = new ca_commerce_communications(); // Get subject line from last message to use as default for replies if (is_array($va_last_transaction = $va_messages_by_transaction[array_pop(array_keys($va_messages_by_transaction))])) { $va_last_message = $va_last_transaction[array_pop(array_keys($va_last_transaction))]; } else { $va_last_message = array('subject' => _t('New inquiry')); } $vs_subject = isset($va_last_message['subject']) ? $va_last_message['subject'] : ''; if (sizeof($va_messages_by_transaction) && !preg_match('!' . _t("Re:") . '!i', $vs_subject)) { $vs_subject = _t("Re:") . ' ' . $vs_subject; } $t_comm->set('subject', $vs_subject); foreach ($t_comm->getFormFields() as $vs_f => $va_info) { switch ($vs_f) { case 'subject': case 'message':
/** * */ public function Info() { $t_comm = new ca_commerce_communications(); $va_unread_messages = $t_comm->getMessages($this->request->getUserID(), array("unreadOnly" => true)); $this->view->setVar("numUnreadMessages", sizeof($va_unread_messages)); return $this->render('widget_communications_info_html.php', true); }
/** * */ 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(); }
/** * */ public function haveAccessToMessage($pn_user_id, $pn_communication_id = null) { $t_user = new ca_users($pn_user_id); if ($t_user->canDoAction('can_manage_clients')) { return true; } if ($pn_communication_id) { $t_comm = new ca_commerce_communications($pn_communication_id); if (!$t_comm->getPrimaryKey()) { return false; } } else { $t_comm = $this; } $t_trans = new ca_commerce_transactions($t_comm->get('transaction_id')); if ($t_trans->getPrimaryKey()) { if ($t_trans->get('user_id') == $pn_user_id) { return true; } } return false; }
?> <a href="#" onclick="jQuery('#caClientOrderCommunicationForm').slideDown(); jQuery('#caClientOrdersComposeButton').hide(); return false;" id="caClientOrdersComposeButton"><?php 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";
/** * */ public function ViewMessage() { $pn_communication_id = $this->request->getParameter('communication_id', pInteger); $t_comm = new ca_commerce_communications($pn_communication_id); if ($t_comm->haveAccessToMessage($this->request->getUserID())) { $this->view->setVar('message', $t_comm); $t_comm->logRead($this->request->getUserID()); $this->view->setVar('messages', $t_comm->getMessages($this->request->getUserID(), array('transaction_id' => $t_comm->get('transaction_id')))); } else { $this->view->setVar('message', null); } $this->render('Sets/view_communication_html.php'); }
/** * */ public function sendMessage($ps_type, $pn_source, $pn_user_id, $ps_subject, $ps_message, $pa_options = null) { if (!($vn_transaction_id = $this->getPrimaryKey())) { return null; } return ca_commerce_communications::sendMessage($vn_transaction_id, $ps_type, $pn_source, $pn_user_id, $ps_subject, $ps_message, $pa_options); }