コード例 #1
0
ファイル: pageHeader.php プロジェクト: guaykuru/pawtucket
                    if ($vb_client_services && is_array($va_message_set_ids) && in_array($va_set["set_id"], $va_message_set_ids)) {
                        print " <img src='" . $this->request->getThemeUrlPath() . "/graphics/icons/envelope.gif' border='0'>";
                    }
                    print "<br/>";
                }
                print "</div>";
                print "</div>";
            } else {
                print caNavLink($this->request, _t("Lightbox"), "", "", "Sets", "Index");
                if ($vb_client_services && is_array($va_message_set_ids) && sizeof($va_message_set_ids)) {
                    print " <img src='" . $this->request->getThemeUrlPath() . "/graphics/icons/envelope.gif' border='0'>";
                }
            }
        }
        if ($vb_client_services && (bool) $o_client_services_config->get('enable_my_account')) {
            $t_order = new ca_commerce_orders();
            if ($vn_num_open_orders = sizeof($va_orders = $t_order->getOrders(array('user_id' => $this->request->getUserID(), 'order_status' => array('OPEN', 'SUBMITTED', 'IN_PROCESSING', 'REOPENED'))))) {
                print "<span style='color: #cc0000; font-weight: bold;'>" . caNavLink($this->request, _t("My Account (%1)", $vn_num_open_orders), "", "", "Account", "Index") . "</span>";
            } else {
                print caNavLink($this->request, _t("My Account"), "", "", "Account", "Index");
            }
        }
        if ($this->request->config->get('enable_bookmarks')) {
            print caNavLink($this->request, _t("My Bookmarks"), "", "", "Bookmarks", "Index");
        }
        print caNavLink($this->request, _t("Logout"), "", "", "LoginReg", "logout");
    } else {
        print caNavLink($this->request, _t("Login/Register"), "", "", "LoginReg", "form");
    }
}
# Locale selection
コード例 #2
0
/**
 * Formats communication for display in messages list
 *
 * @param RequestHTTP $po_request
 * @param array $pa_data
 * @param array $pa_options
 *		viewContentDivID = 
 *		additionalMessages =
 *		isAdditionalMessage =
 *
 * @return string 
 */
function caClientServicesFormatMessageSummary($po_request, $pa_data, $pa_options = null)
{
    $vb_is_additional_message = (bool) (isset($pa_options['isAdditionalMessage']) && $pa_options['isAdditionalMessage']);
    $vb_is_unread = !(bool) $pa_data['read_on'];
    $vs_unread_class = $vb_is_unread ? "caClientCommunicationsMessageSummaryUnread" : "";
    if ($pa_data['source'] == __CA_COMMERCE_COMMUNICATION_SOURCE_INSTITUTION__) {
        $vb_is_unread = false;
        $vs_unread_class = '';
    }
    // institution-sent messages are never unread in Providence
    if ($vb_is_additional_message) {
        $vs_class = $vb_is_unread ? "caClientCommunicationsAdditionalMessageSummary caClientCommunicationsMessageSummaryUnread" : "caClientCommunicationsAdditionalMessageSummary";
        $vs_buf = "<div class='{$vs_class}' id='caClientCommunicationsMessage_" . $pa_data['communication_id'] . "'>";
    } else {
        $vs_class = $vb_is_unread ? "caClientCommunicationsMessageSummary caClientCommunicationsMessageSummaryUnread" : "caClientCommunicationsMessageSummary";
        $vs_buf = "<div class='{$vs_class}'>";
    }
    $vs_buf .= "<div class='caClientCommunicationsMessageSummaryContainer' id='caClientCommunicationsMessage_" . $pa_data['communication_id'] . "'>";
    $vs_buf .= "<div class='caClientCommunicationsViewMessageIcon'>+</div>";
    TooltipManager::add(".caClientCommunicationsViewMessageIcon", _t("View entire message and associated media"));
    $vs_buf .= "<div class='caClientCommunicationsMessageSummaryFrom {$vs_unread_class}'><span class='caClientCommunicationsMessageSummaryHeading'>" . _t("From") . ":</span> " . caClientServicesGetSenderName($pa_data);
    $vs_buf .= $vb_is_unread ? " <img src='" . $po_request->getThemeUrlPath() . "/graphics/icons/envelope.gif' border='0'>" : "";
    $vs_buf .= "</div>";
    $vs_buf .= "<div class='caClientCommunicationsMessageSummaryDate {$vs_unread_class}'><span class='caClientCommunicationsMessageSummaryHeading'>" . _t("Date") . ":</span> " . caGetLocalizedDate($pa_data['created_on'], array('dateFormat' => 'delimited')) . "</div>";
    $vs_buf .= "<div class='caClientCommunicationsMessageSummarySubject {$vs_unread_class}'><span class='caClientCommunicationsMessageSummaryHeading'>" . _t("Subject") . ":</span> " . $pa_data['subject'] . "</div>";
    $vs_buf .= "<div class='caClientCommunicationsMessageSummaryText'>" . (mb_strlen($pa_data['message']) > 100 ? mb_substr($pa_data['message'], 0, 100) . "..." : $pa_data['message']) . "</div>";
    $vn_num_additional_messages = is_array($pa_options['additionalMessages']) ? sizeof($pa_options['additionalMessages']) : 0;
    // are there orders linked to this thread?
    if ($vn_num_orders = sizeof($va_order_ids = ca_commerce_orders::getOrderIDsForTransaction($pa_data['transaction_id']))) {
        $vs_buf .= "<div class='caClientCommunicationsMessageSummaryThreadButton'>" . caNavLink($po_request, ($vn_num_orders == 1 ? _t('%1 order', $vn_num_orders) : _t('%1 orders', $vn_num_orders)) . " &rsaquo;", 'button', 'client', 'Orders', 'Index', array('transaction_id' => $pa_data['transaction_id'])) . "</div>\n";
    }
    if ($vn_num_additional_messages) {
        $vs_buf .= "<div class='caClientCommunicationsMessageSummaryThreadButton' id='caClientCommunicationsMessageAdditionalCount" . $pa_data['communication_id'] . "'><a href='#' onclick='jQuery(\"#caClientCommunicationsMessageAdditional" . $pa_data['communication_id'] . "\").slideToggle(250, function(){ if(jQuery(\"#caClientCommunicationsMessageViewThread" . $pa_data['communication_id'] . "\").html() == \"" . _t("view thread") . " &rsaquo;\") {jQuery(\"#caClientCommunicationsMessageViewThread" . $pa_data['communication_id'] . "\").html(\"" . _t("hide thread") . " &rsaquo;\")}else{jQuery(\"#caClientCommunicationsMessageViewThread" . $pa_data['communication_id'] . "\").html(\"" . _t("view thread") . " &rsaquo;\")}}); return false;' id='caClientCommunicationsMessageViewThread" . $pa_data['communication_id'] . "' class='button'>" . _t("view thread") . " &rsaquo;</a></div>\n";
    }
    $vs_buf .= "</div>";
    if ($vn_num_additional_messages) {
        $vs_buf .= "<div class='caClientCommunicationsMessageAdditional' id='caClientCommunicationsMessageAdditional" . $pa_data['communication_id'] . "'>";
        $pa_additional_options = $pa_options;
        unset($pa_additional_options['additionalMessages']);
        $pa_additional_options['isAdditionalMessage'] = true;
        foreach ($pa_options['additionalMessages'] as $va_additional_message) {
            $vs_buf .= caClientServicesFormatMessageSummary($po_request, $va_additional_message, $pa_additional_options);
        }
        $vs_buf .= "</div>";
    }
    $vs_buf .= "</div>\n";
    return $vs_buf;
}
コード例 #3
0
 * This program is free software; you may redistribute it and/or modify it under
 * the terms of the provided license as published by Whirl-i-Gig
 *
 * CollectiveAccess is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTIES whatsoever, including any implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 *
 * This source code is free and modifiable under the terms of 
 * GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See
 * the "license.txt" file for details, or visit the CollectiveAccess web site at
 * http://www.CollectiveAccess.org
 *
 * ----------------------------------------------------------------------
 */
?>
 	<h3><?php 
print _t('Client check-out');
?>
:
	<div><?php 
$t_order = new ca_commerce_orders();
$va_outstanding_loans = $t_order->getOrders(array('type' => 'L', 'is_outstanding' => true));
$vn_num_outstanding_loans = sizeof($va_outstanding_loans);
$va_overdue_loans = $t_order->getOrders(array('type' => 'L', 'is_overdue' => true));
$vn_num_overdue_loans = sizeof($va_overdue_loans);
print $vn_num_outstanding_loans == 1 ? _t('%1 outstanding loan', $vn_num_outstanding_loans) : _t('%1 outstanding loans', $vn_num_outstanding_loans);
print "<br/>\n";
print $vn_num_overdue_loans == 1 ? _t('%1 overdue loan', $vn_num_overdue_loans) : _t('%1 overdue loans', $vn_num_overdue_loans);
?>
</div>
	</h3>
コード例 #4
0
ファイル: ca_objects.php プロジェクト: guaykuru/pawtucket
 /**
  * Returns history of client orders. Orders are sorted most recent first.
  *
  * @param string $ps_order_type Type of order to return history for. L=loans, O=sales orders. If set to any other value all types of orders will be returned.
  * @return array List of orders
  */
 public function getClientHistory($ps_order_type)
 {
     if (!$this->getPrimaryKey()) {
         return null;
     }
     $vn_object_id = $this->getPrimaryKey();
     $ps_order_type = strtoupper($ps_order_type);
     $va_options = array();
     if (!in_array($ps_order_type, array('O', 'L'))) {
         $ps_order_type = null;
     } else {
         $va_options['type'] = $ps_order_type;
     }
     $va_orders = ca_commerce_orders::getUsageOfItemInOrders($vn_object_id, $va_options);
     $va_history = array();
     foreach ($va_orders as $vn_id => $va_order) {
         $va_order['loan_checkout_date_raw'] = $va_order['loan_checkout_date'];
         $va_order['loan_checkout_date'] = caGetLocalizedDate($va_order['loan_checkout_date'], array('timeOmit' => true, 'dateFormat' => 'delimited'));
         $va_order['loan_due_date_raw'] = $va_order['loan_due_date'];
         $va_order['loan_due_date'] = $va_order['loan_due_date'] ? caGetLocalizedDate($va_order['loan_due_date'], array('timeOmit' => true, 'dateFormat' => 'delimited')) : '';
         $va_order['loan_return_date_raw'] = $va_order['loan_return_date'];
         $va_order['loan_return_date'] = $va_order['loan_return_date'] ? caGetLocalizedDate($va_order['loan_return_date'], array('timeOmit' => true, 'dateFormat' => 'delimited')) : '';
         $va_order['order_number'] = ca_commerce_orders::generateOrderNumber($va_order['order_id'], $va_order['created_on']);
         $va_history[$va_order['loan_checkout_date']] = $va_order;
     }
     ksort($va_history);
     return array_reverse($va_history);
 }
コード例 #5
0
 public function update($pa_options = null)
 {
     if (!$this->_preSaveActions()) {
         return false;
     }
     $vn_old_status = $this->getOriginalValue('order_status');
     $vn_old_ship_date = $this->getOriginalValue('shipping_date');
     $vn_old_shipped_on_date = $this->getOriginalValue('shipped_on_date');
     // Move order status automatically to reflect business logic
     switch ($this->get('order_status')) {
         case 'PROCESSED':
             if ($this->get('shipped_on_date') && $this->changed('shipped_on_date') && !$this->requiresDownload()) {
                 // If it shipped and there's nothing left to fulfill by download then ship status to "complete"
                 $this->set('order_status', 'COMPLETED');
             }
             break;
         case 'AWAITING_PAYMENT':
             if ($this->get('payment_received_on') && $this->changed('payment_received_on') || $this->getTotal() == 0) {
                 if ($this->get('order_type') == 'L') {
                     // LOANS
                     $this->set('order_status', 'PROCESSED');
                 } else {
                     // SALES ORDERS
                     // If it paid for then flip status to "PROCESSED" (if it's all ready to go) or "PROCESSED_AWAITING_DIGITIZATION" if stuff needs to be digitized
                     if (sizeof($va_items_with_no_media = $this->itemsWithNoDownloadableMedia()) > 0) {
                         $this->set('order_status', 'PROCESSED_AWAITING_DIGITIZATION');
                     } else {
                         // If "original" files are missing then mark as PROCESSED_AWAITING_MEDIA_ACCESS
                         if (sizeof($va_items_missing_media = $this->itemsMissingDownloadableMedia('original'))) {
                             $this->set('order_status', 'PROCESSED_AWAITING_MEDIA_ACCESS');
                         } else {
                             $this->set('order_status', 'PROCESSED');
                         }
                     }
                 }
             }
             break;
     }
     $vb_status_changed = $this->changed('order_status');
     $this->set('order_number', ca_commerce_orders::generateOrderNumber($this->getPrimaryKey(), $this->get('created_on', array('GET_DIRECT_DATE' => true))));
     if ($vn_rc = parent::update($pa_options)) {
         if ($vb_status_changed) {
             $this->sendStatusChangeEmailNotification($vn_old_status, $vn_old_ship_date, $vn_old_shipped_on_date);
         }
         if (in_array($this->get('order_status'), array('PROCESSED', 'PROCESSED_AWAITING_DIGITIZATION', 'PROCESSED_AWAITING_MEDIA_ACCESS', 'COMPLETED'))) {
             // Delete originating set if configured to do so
             if ($this->opo_client_services_config->get('set_disposal_policy') == 'DELETE_WHEN_ORDER_PROCESSED') {
                 $t_trans = new ca_commerce_transactions($this->get('transaction_id'));
                 if ($t_trans->getPrimaryKey()) {
                     $t_set = new ca_sets($t_trans->get('set_id'));
                     if ($t_set->getPrimaryKey()) {
                         $t_set->setMode(ACCESS_WRITE);
                         $t_set->delete(true);
                     }
                 }
             }
         }
     }
     return $vn_rc;
 }
コード例 #6
0
 /**
  * 
  */
 public function Info($pa_options = null)
 {
     $t_order = new ca_commerce_orders();
     $this->view->setVar('order_list', $va_order_list = $t_order->getOrders($pa_options));
     return $this->render('widget_checkin_info_html.php', true);
 }
コード例 #7
0
 *
 * This program is free software; you may redistribute it and/or modify it under
 * the terms of the provided license as published by Whirl-i-Gig
 *
 * CollectiveAccess is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTIES whatsoever, including any implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 *
 * This source code is free and modifiable under the terms of 
 * GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See
 * the "license.txt" file for details, or visit the CollectiveAccess web site at
 * http://www.CollectiveAccess.org
 *
 * ----------------------------------------------------------------------
 */
$t_order = new ca_commerce_orders();
$t_item = new ca_commerce_order_items();
$va_order_list = $this->getVar('order_list');
$vn_num_orders = sizeof($va_order_list);
$va_filter_options = $this->getVar('filter_options');
$vs_currency_symbol = $this->getVar('currency_symbol');
$va_display_list = array('order_number' => _t('Order #'), 'created_on' => _t('Created'), 'client' => _t('Client'), 'summary' => _t('Summary'), 'order_status' => _t('Status'), 'total' => _t('Total'), 'shipping' => _t('Shipping'));
?>
<style type="text/css">
<!--
/* commentaire dans un css */
table, td { border: 1px solid #000000; color: #000000; text-wrap: normal; width: 135px; height: 120px; padding: 5px; font-size: 11px;}
td.odd   { color: #00AA00; }
.displayHeader { background-color: #EEEEEE; padding: 5px; border: 1px solid #999999; font-size: 12px; }
#pageHeader { background-color: #<?php 
print $this->request->config->get('report_color');
コード例 #8
0
 public function RecordRepresentationSelection()
 {
     $pn_item_id = $this->request->getParameter('item_id', pInteger);
     $pn_representation_id = $this->request->getParameter('representation_id', pInteger);
     $pn_selected = $this->request->getParameter('selected', pInteger);
     $va_errors = array();
     $t_order_item = new ca_commerce_order_items($pn_item_id);
     if (!$t_order_item->getPrimaryKey()) {
         $va_errors[] = _t("Invalid set item");
     }
     if (!sizeof($va_errors)) {
         $t_order = new ca_commerce_orders($t_order_item->get('order_id'));
         if (!$t_order->getPrimaryKey()) {
             $va_errors[] = _t("Invalid order");
         }
         if (!sizeof($va_errors)) {
             if ((bool) $pn_selected) {
                 $t_order_item->addRepresentations(array($pn_representation_id));
             } else {
                 $t_order_item->removeRepresentations(array($pn_representation_id));
             }
             $va_errors = $t_order_item->getErrors();
         }
     }
     $this->view->setVar("errors", $va_errors);
     $this->view->setVar('representation_id', $pn_representation_id);
     $this->view->setVar('item_id', $pn_item_id);
     $this->render("ajax_select_representation_json.php");
 }
コード例 #9
0
 /**
  * 
  */
 public function Info()
 {
     $t_order = new ca_commerce_orders();
     $this->view->setVar('order_list', $va_order_list = $t_order->getOrders(array('type' => 'O')));
     return $this->render('widget_orders_info_html.php', true);
 }
コード例 #10
0
 /**
  * Perform client services-related periodic tasks
  */
 public function hookPeriodicTask(&$pa_params)
 {
     $t_log = new Eventlog();
     $o_db = new Db();
     if (!(bool) $this->opo_config->get('enable_client_services')) {
         return true;
     }
     // Find any orders with status PROCESSED_AWAITING_MEDIA_ACCESS and fetch media
     $qr_orders = $o_db->query("\n\t\t\t\tSELECT order_id\n\t\t\t\tFROM ca_commerce_orders\n\t\t\t\tWHERE\n\t\t\t\t\torder_status = 'PROCESSED_AWAITING_MEDIA_ACCESS'\n\t\t\t");
     //
     // Set up HTTP client for REST calls
     //
     if ($this->opo_client_services_config->get('remote_media_base_url')) {
         $vs_base_url = $this->opo_client_services_config->get('remote_media_base_url');
         $o_client = new RestClient($vs_base_url . "/service.php/iteminfo/ItemInfo/rest");
         try {
             $o_res = $o_client->auth($this->opo_client_services_config->get('remote_media_username'), $this->opo_client_services_config->get('remote_media_password'))->get();
             if (!$o_res->isSuccess()) {
                 $t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('Could not authenticate to remote system %1', $vs_base_url), 'SOURCE' => 'clientServicesPlugin->hookPeriodicTask'));
             }
             while ($qr_orders->nextRow()) {
                 $t_order = new ca_commerce_orders($qr_orders->get('order_id'));
                 $vb_download_errors = false;
                 if ($t_order->getPrimaryKey() && sizeof($va_missing_media = $t_order->itemsMissingDownloadableMedia())) {
                     $va_missing_media_representation_ids = $t_order->itemsMissingDownloadableMedia('original', array('returnRepresentationIDs' => true));
                     foreach ($va_missing_media as $vn_object_id => $va_representation_md5s) {
                         foreach ($va_representation_md5s as $vn_i => $vs_representation_md5) {
                             $o_xml = $o_client->getObjectRepresentationURLByMD5($vs_representation_md5, 'original')->get();
                             $vs_url = (string) $o_xml->getObjectRepresentationURLByMD5->original;
                             if (!$vs_url) {
                                 continue;
                             }
                             // media no longer exists
                             // fetch the file
                             $t_rep = new ca_object_representations($va_missing_media_representation_ids[$vn_object_id][$vn_i]);
                             if ($t_rep->getPrimaryKey() && ($vs_target_path = $t_rep->getMediaPath('media', 'original'))) {
                                 if ($r_source = fopen($vs_url, "rb")) {
                                     if ($r_target = fopen($vs_target_path, "wb")) {
                                         while (feof($r_source) === false) {
                                             fwrite($r_target, fread($r_source, 1024 * 8), 1024 * 8);
                                         }
                                         fclose($r_target);
                                     } else {
                                         $vb_download_errors = true;
                                         $t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('Could not open target path %1', $vs_target_path), 'SOURCE' => 'clientServicesPlugin->hookPeriodicTask'));
                                     }
                                     fclose($r_source);
                                 } else {
                                     $vb_download_errors = true;
                                     $t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('Could not open download URL "%1"', $vs_url), 'SOURCE' => 'clientServicesPlugin->hookPeriodicTask'));
                                 }
                                 // verify the file was downloaded correctly
                                 if (($vs_target_md5 = md5_file($vs_target_path)) !== $vs_representation_md5) {
                                     unlink($vs_target_path);
                                     $t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('Media file %1 failed to be downloaded from url "%2"; checksums differ: %3/%4', $vs_target_path, $vs_url, $vs_representation_md5, $vs_target_md5), 'SOURCE' => 'clientServicesPlugin->hookPeriodicTask'));
                                     $vb_download_errors = true;
                                 }
                             } else {
                                 $t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('Invalid representation_id "%1" or target path "%2"', $vn_representation_id, $vs_representation_md5, $vs_target_path), 'SOURCE' => 'clientServicesPlugin->hookPeriodicTask'));
                                 $vb_download_errors = true;
                             }
                         }
                     }
                 }
                 if (!$vb_download_errors) {
                     $t_order->setMode(ACCESS_WRITE);
                     $t_order->set('order_status', 'PROCESSED');
                     $t_order->update();
                     if ($t_order->numErrors()) {
                         $t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('Change of order status to PROCESSED from PROCESSED_AWAITING_MEDIA_ACCESS failed for order_id %1: %2', $t_order->getPrimaryKey(), join('; ', $t_order->getErrors())), 'SOURCE' => 'clientServicesPlugin->hookPeriodicTask'));
                     }
                 }
             }
         } catch (Exception $e) {
             // noop
         }
     }
     // Find any orders with status PROCESSED_AWAITING_DIGITIZATION where all media are now present
     $qr_orders = $o_db->query("\n\t\t\t\tSELECT order_id\n\t\t\t\tFROM ca_commerce_orders\n\t\t\t\tWHERE\n\t\t\t\t\torder_status = 'PROCESSED_AWAITING_DIGITIZATION'\n\t\t\t");
     while ($qr_orders->nextRow()) {
         $t_order = new ca_commerce_orders($qr_orders->get('order_id'));
         if ($t_order->getPrimaryKey() && !sizeof($t_order->itemsWithNoDownloadableMedia())) {
             $t_order->setMode(ACCESS_WRITE);
             $t_order->set('order_status', 'PROCESSED');
             $t_order->update();
             if ($t_order->numErrors()) {
                 $t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('Change of order status to PROCESSED from PROCESSED_AWAITING_DIGITIZATION failed for order_id %1: %2', $t_order->getPrimaryKey(), join('; ', $t_order->getErrors())), 'SOURCE' => 'clientServicesPlugin->hookPeriodicTask'));
             }
         }
     }
     // Find orders paid/shipped more than X days ago and mark them as "COMPLETED"
     $vn_days = (int) $this->opo_client_services_config->get('completed_order_age_threshold');
     if ($vn_days > 1) {
         $vn_threshold = (int) (time() - $vn_days * 24 * 60 * 60);
         $qr_orders = $o_db->query("\n\t\t\t\t\tSELECT order_id\n\t\t\t\t\tFROM ca_commerce_orders\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(order_status = 'PROCESSED') \n\t\t\t\t\t\tAND \n\t\t\t\t\t\t((payment_received_on > 0) AND (payment_received_on < ?))\n\t\t\t\t\t\tAND \n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t(shipping_date IS NULL AND shipped_on_date IS NULL)\n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t(shipped_on_date > 0) AND (shipped_on_date < ?)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t", $vn_threshold, $vn_threshold);
         while ($qr_orders->nextRow()) {
             $t_order = new ca_commerce_orders($qr_orders->get('order_id'));
             if ($t_order->getPrimaryKey()) {
                 $t_order->setMode(ACCESS_WRITE);
                 $t_order->set('order_status', 'COMPLETED');
                 $t_order->update();
                 if ($t_order->numErrors()) {
                     $t_log->log(array('CODE' => 'ERR', 'MESSAGE' => _t('Change of order status to COMPLETED from PROCESSED failed for order_id %1: %2', $t_order->getPrimaryKey(), join('; ', $t_order->getErrors())), 'SOURCE' => 'clientServicesPlugin->hookPeriodicTask'));
                 }
             }
         }
     }
     return true;
 }
コード例 #11
0
 /**
  *
  */
 public function Download()
 {
     $pn_item_id = $this->request->getParameter('item_id', pInteger);
     $t_item = new ca_commerce_order_items($pn_item_id);
     $t_order = new ca_commerce_orders($t_item->get('order_id'));
     $t_transaction = new ca_commerce_transactions($t_order->get('transaction_id'));
     $o_media = new Media();
     if ($t_item->getPrimaryKey() && $t_order->getPrimaryKey()) {
         // Is the order paid for...
         if (!in_array($t_order->get('order_status'), array('PROCESSED', 'PROCESSED_AWAITING_DIGITIZATION', 'COMPLETED'))) {
             $this->notification->addNotification(_t("This order must be processed before you can download items"), __NOTIFICATION_TYPE_ERROR__);
             $this->Index();
             return;
         }
         // ... and accessible by this user?
         if ($t_transaction->get('user_id') != $this->request->getUserID()) {
             $this->notification->addNotification(_t("You may not download this item"), __NOTIFICATION_TYPE_ERROR__);
             $this->Index();
             return;
         }
         // Is this item downloadable?
         if ($t_item->get('fullfillment_method') != 'DOWNLOAD') {
             $this->notification->addNotification(_t("This item cannot be downloaded"), __NOTIFICATION_TYPE_ERROR__);
             $this->Index();
             return;
         }
         // Which reps, and what versions?
         $t_object = new ca_objects($t_item->get('object_id'));
         $va_services_list = array();
         if (is_array($va_service_groups = $this->opo_client_services_config->getAssoc("service_groups"))) {
             foreach ($va_service_groups as $vs_group => $va_services_in_group) {
                 foreach ($va_services_in_group['services'] as $vs_service => $va_service_info) {
                     $va_services_list[$vs_service] = $va_service_info;
                 }
             }
         }
         if (!($vs_version = $va_services_list[$t_item->get('service')]['download_version'])) {
             $vs_version = 'small';
         }
         $va_reps = $t_object->getRepresentations(array($vs_version));
         $va_reps_to_download = $t_item->getRepresentationIDs();
         $o_zip = new ZipFile();
         $va_files = array();
         $vn_size = 0;
         foreach ($va_reps as $va_rep) {
             if (!isset($va_reps_to_download[$va_rep['representation_id']]) || !$va_reps_to_download[$va_rep['representation_id']]) {
                 continue;
             }
             $va_tmp = explode('.', $va_rep['paths'][$vs_version]);
             $vs_ext = array_pop($va_tmp);
             if ($va_rep['original_filename']) {
                 $va_tmp2 = explode(".", $va_rep['original_filename']);
                 if (sizeof($va_tmp2) > 1) {
                     array_pop($va_tmp2);
                 }
                 $vs_filename = join(".", $va_tmp2) . ".{$vs_ext}";
             } else {
                 $vs_filename = $t_object->get('idno') . "_" . $va_rep['representation_id'] . ".{$vs_ext}";
             }
             $vn_size += $va_files[$va_rep['paths'][$vs_version]] = filesize($va_rep['paths'][$vs_version]);
             $o_zip->addFile($va_rep['paths'][$vs_version], $vs_filename, 0, array('compression' => 0));
         }
         $this->view->setVar('zip', $o_zip);
         $this->view->setVar('version_download_name', date('dmY', $t_order->get('created_on', array('GET_DIRECT_DATE' => true))) . '-' . $t_order->getPrimaryKey());
         // Log fulfillment
         $t_item->logFulfillmentEvent('DOWNLOAD', array('ip_addr' => $_SERVER['REMOTE_ADDR'], 'user_id' => $this->request->getUserID(), 'datetime' => time(), 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'files' => $va_files, 'size' => $vn_size, 'representation_ids' => $va_reps_to_download));
         return $this->render('Account/download_binary.php');
     }
     $this->notification->addNotification(_t("You may not download this"), __NOTIFICATION_TYPE_ERROR__);
     $this->Index();
     return;
 }