Ejemplo n.º 1
0
 function doBulkUpdate($filter, $do, $ids = array())
 {
     @set_time_limit(0);
     $change_fields = array();
     $custom_fields = array();
     // Make sure we have actions
     if (empty($do)) {
         return;
     }
     // Make sure we have checked items if we want a checked list
     if (0 == strcasecmp($filter, "checks") && empty($ids)) {
         return;
     }
     if (is_array($do)) {
         foreach ($do as $k => $v) {
             switch ($k) {
                 //			$change_fields[DAO_CustomerAccount::ID] = intval($v);
                 //			$change_fields[DAO_CustomerAccount::ACCOUNT_NUMBER] = intval($v);
                 //			$change_fields[DAO_CustomerAccount::ACCOUNT_NAME] = intval($v);
                 //			$change_fields[DAO_CustomerAccount::IMPORT_SOURCE] = intval($v);
                 // [TODO] Implement actions FIXME after bulkupdate form created
                 case 'is_disabled':
                     $change_fields[DAO_CustomerAccount::IS_DISABLED] = intval($v);
                     break;
                 default:
                     // Custom fields
                     if (substr($k, 0, 3) == "cf_") {
                         $custom_fields[substr($k, 3)] = $v;
                     }
             }
         }
     }
     $pg = 0;
     if (empty($ids)) {
         do {
             list($objects, $null) = DAO_CustomerAccount::search(array(), $this->params, 100, $pg++, SearchFields_CustomerAccount::ID, true, false);
             $ids = array_merge($ids, array_keys($objects));
         } while (!empty($objects));
     }
     $batch_total = count($ids);
     for ($x = 0; $x <= $batch_total; $x += 100) {
         $batch_ids = array_slice($ids, $x, 100);
         DAO_CustomerAccount::update($batch_ids, $change_fields);
         // Custom Fields
         self::_doBulkSetCustomFields(FegCustomFieldSource_CustomerAccount::ID, $custom_fields, $batch_ids);
         unset($batch_ids);
     }
     unset($ids);
 }
Ejemplo n.º 2
0
 function saveCustomerAccountAction()
 {
     @($customer_id = DevblocksPlatform::importGPC($_REQUEST['customer_id'], 'integer', 0));
     @($and_close = DevblocksPlatform::importGPC($_POST['and_close'], 'integer', 0));
     @($id = DevblocksPlatform::importGPC($_POST['id'], 'integer'));
     @($disabled = DevblocksPlatform::importGPC($_POST['account_is_disabled'], 'integer', 0));
     @($import_source = DevblocksPlatform::importGPC($_POST['customer_account_import_source'], 'integer', 0));
     @($account_number = DevblocksPlatform::importGPC($_REQUEST['customer_account_number'], 'string', ''));
     @($account_name = DevblocksPlatform::importGPC($_REQUEST['customer_account_name'], 'string', ''));
     $fields = array(DAO_CustomerAccount::IMPORT_SOURCE => $import_source, DAO_CustomerAccount::ACCOUNT_NAME => $account_name, DAO_CustomerAccount::ACCOUNT_NUMBER => $account_number, DAO_CustomerAccount::IS_DISABLED => $disabled);
     // Update Customer Recipients
     $status = DAO_CustomerAccount::update($customer_id, $fields);
     if ($and_close) {
         DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('account')));
     } else {
         DevblocksPlatform::redirect(new DevblocksHttpResponse(array('customer', $customer_id, 'property')));
     }
 }