Jump to content

Only one edited column will save in Admin Customers


Claudia

Recommended Posts

admin/skin/customer.index

 

<thead>

                        <tr>

                          <td width="32">&nbsp;</td>

                          <td>{$THEAD.status}</td>

                          <td>{$THEAD.type}</td>

                          <td>{$THEAD.customer}</td>

                          <td>{$THEAD.venue_id}</td>

                          <td>{$THEAD.venue_sold_site}</td>

                           <td>{$THEAD.email}</td>

                          <td>{$THEAD.registered}</td>

                          <td>{$THEAD.no_orders}</td>

                          <td>&nbsp;</td>

                        </tr>

              </thead>

 

 <td><a href="{$customer.edit}">{$customer.last_name}, {$customer.first_name}</a> {if !empty($customer.groups)}({$customer.groups}){/if}</td>

                          <td><span class="editable" name="venue_id[{$customer.customer_id}]">{$customer.venue_id}</span></td>

                           <td><span class="editable" name="venue_sold_site[{$customer.customer_id}]">{$customer.venue_sold_site}</span></td>

                      <td>{$customer.email}</td>

 

              <fieldset><legend>{$LANG.account.contact_details}</legend>

                <div><label style="width: 15em" for="venue_sold_site">Venue Sold Site</label><span><input type="text" name="customer[venue_sold_site]" id="venue_sold_site" value="{$CUSTOMER.venue_sold_site}" class="textbox"></span></div>

               <div><label style="width: 15em" for="venue_id">Venue ID</label><span><input type="text" name="customer[venue_id]" id="venue_id" value="{$CUSTOMER.venue_id}" class="textbox"></span></div>

             <div><label style="width: 15em" for="venue_email">Venue eMail</label><span><input type="text" name="customer[venue_email]" id="venue_email" value="{$CUSTOMER.venue_email}" class="textbox"></span></div>

 

admin/source/customer.index.inc

 

  $GLOBALS['main']->successMessage($lang['customer']['notify_groups_delete']);

        $send_redirect = true;

    }

      if (isset($_POST['venue_sold_site']) && is_array($_POST['venue_sold_site']) && Admin::getInstance()->permissions('customers', CC_PERM_EDIT)) {

        foreach ($_POST['venue_sold_site'] as $customer_id => $venue_sold_site) {

            $result = $result || $GLOBALS['db']->update('CubeCart_customer', array('venue_sold_site' => $venue_sold_site), array('customer_id' => (int)$customer_id));

        }

        if ($result) {

            $GLOBALS['main']->successMessage("Some or all venue sold sites updated.");

        }

        $send_redirect = true;

    }

  if (isset($_POST['venue_id']) && is_array($_POST['venue_id']) && Admin::getInstance()->permissions('customers', CC_PERM_EDIT)) {

        foreach ($_POST['venue_id'] as $customer_id => $venue_id) {

            $result = $result || $GLOBALS['db']->update('CubeCart_customer', array('venue_id' => $venue_id), array('customer_id' => (int)$customer_id));

        }

        if ($result) {

            $GLOBALS['main']->successMessage("Some or all venue id updated.");

        }

        $send_redirect = true;

    }

 

  $thead_sort = array(

        'status'   => $GLOBALS['db']->column_sort('status', $lang['common']['status'], 'sort', $current_page, $_GET['sort']),

        'customer'   => $GLOBALS['db']->column_sort('customer', $lang['customer']['title_customer'], 'sort', $current_page, $_GET['sort']),

      'venue_sold_site'   => $GLOBALS['db']->column_sort('venue_sold_site', 'Sold Site', 'sort', $current_page, $_GET['sort']),

      'venue_id'   => $GLOBALS['db']->column_sort('venue_id', 'Venue ID', 'sort', $current_page, $_GET['sort']),

        'registered' => $GLOBALS['db']->column_sort('registered', $lang['customer']['date_registered'], 'sort', $current_page, $_GET['sort']),

        'type'   => $GLOBALS['db']->column_sort('type', $lang['customer']['customer_type'], 'sort', $current_page, $_GET['sort']),

        'email'   => $GLOBALS['db']->column_sort('email', $lang['common']['email'], 'sort', $current_page, $_GET['sort']),

        'no_orders'  => $GLOBALS['db']->column_sort('order_count', $lang['customer']['order_count'], 'sort', $current_page, $_GET['sort']),

        'language'  => $GLOBALS['db']->column_sort('language', $lang['common']['language'], 'sort', $current_page, $_GET['sort'])

    );

Link to comment
Share on other sites

This part of each of two statements:

$result = $result || $GLOBALS['db']->update('CubeCart_customer'

PHP will first analyze the statement to 'optimize' it. In doing so, the conclusion is that either $result or update() must be true. PHP will first evaluate $result and, if that is true-like, won't bother with the rest of the statement -- it has its true-ness and that is all that mattered.

So, this is what I recommend:

$venue_sold_site = false;
foreach ($_POST['venue_sold_site'] as $customer_id => $venue_sold_site) {
  if (($GLOBALS['db']->update(
       'CubeCart_customer',
       array('venue_sold_site' => $venue_sold_site),
       array('customer_id' => (int)$customer_id))
     ) !==false) { $venue_sold_site = true; }
}
if ($venue_sold_site) { $GLOBALS['main']->successMessage("Some or all venue sold sites updated."); }

Do the same for the other POST column.

 

Link to comment
Share on other sites

In admin/source/customer.index.inc, find:

    if (isset($_POST['venue_sold_site']) && is_array($_POST['venue_sold_site']) && Admin::getInstance()->permissions('customers', CC_PERM_EDIT)) {
        foreach ($_POST['venue_sold_site'] as $customer_id => $venue_sold_site) {
            $result = $result || $GLOBALS['db']->update('CubeCart_customer', array('venue_sold_site' => $venue_sold_site), array('customer_id' => (int)$customer_id));
        }
        if ($result) {
            $GLOBALS['main']->successMessage("Some or all venue sold sites updated.");
        }
        $send_redirect = true;
    }

    if (isset($_POST['venue_id']) && is_array($_POST['venue_id']) && Admin::getInstance()->permissions('customers', CC_PERM_EDIT)) {
        foreach ($_POST['venue_id'] as $customer_id => $venue_id) {
            $result = $result || $GLOBALS['db']->update('CubeCart_customer', array('venue_id' => $venue_id), array('customer_id' => (int)$customer_id));
        }
        if ($result) {
            $GLOBALS['main']->successMessage("Some or all venue id updated.");
        }
        $send_redirect = true;
    }


Replace with:

    if (isset($_POST['venue_sold_site']) && is_array($_POST['venue_sold_site']) && Admin::getInstance()->permissions('customers', CC_PERM_EDIT)) {
        $venue_sold_site = false;
        foreach ($_POST['venue_sold_site'] as $customer_id => $venue_sold_site) {
            if (($GLOBALS['db']->update('CubeCart_customer', array('venue_sold_site' => $venue_sold_site), array('customer_id' => (int)$customer_id))) !==false) { $venue_sold_site = true; }
        }
        if ($venue_sold_site) { $GLOBALS['main']->successMessage("Some or all venue sold sites updated."); }
        $send_redirect = true;
    }

    if (isset($_POST['venue_id']) && is_array($_POST['venue_id']) && Admin::getInstance()->permissions('customers', CC_PERM_EDIT)) {
        $venue_id = false;
        foreach ($_POST['venue_id'] as $customer_id => $venue_id) {
            if (($GLOBALS['db']->update('CubeCart_customer', array('venue_id' => $venue_id), array('customer_id' => (int)$customer_id))) !==false) { $venue_id = true; }
        }
        if ($venue_id) { $GLOBALS['main']->successMessage("Some or all venue id updated."); }
        $send_redirect = true;
    }

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...