Exemple #1
0
         $type += CONTACT_LANDLINE;
     }
     $customeradd['contacts'][$idx]['type'] = $type;
     if ($name && !$phone) {
         $error['contact' . $idx] = trans('Phone number is required!');
     } elseif ($phone) {
         $contacts[] = array('name' => $name, 'contact' => $phone, 'type' => empty($type) ? CONTACT_LANDLINE : $type);
     }
 }
 foreach ($customeradd['accounts'] as $idx => $val) {
     $account = trim($val['account']);
     $name = trim($val['name']);
     $type = !empty($val['type']) ? array_sum($val['type']) : NULL;
     $type += CONTACT_BANKACCOUNT;
     $customeradd['accounts'][$idx]['type'] = $type;
     if ($account != '' && !check_bankaccount($account)) {
         $error['account' . $idx] = trans('Incorrect bank account!');
     } elseif ($name && !$account) {
         $error['account' . $idx] = trans('Bank account is required!');
     } elseif ($account) {
         $contacts[] = array('name' => $name, 'contact' => $account, 'type' => $type);
     }
 }
 if ($customeradd['cutoffstop'] == '') {
     $cutoffstop = 0;
 } elseif (check_date($customeradd['cutoffstop'])) {
     list($y, $m, $d) = explode('/', $customeradd['cutoffstop']);
     if (checkdate($m, $d, $y)) {
         $cutoffstop = mktime(23, 59, 59, $m, $d, $y);
     } else {
         $error['cutoffstop'] = trans('Incorrect date of cutoff suspending!');
function validate_customer_accounts(&$customerdata, &$contacts, &$error)
{
    foreach ($customerdata['accounts'] as $idx => &$val) {
        $account = trim($val['contact']);
        $name = trim($val['name']);
        $type = !empty($val['type']) ? array_sum($val['type']) : NULL;
        $type |= CONTACT_BANKACCOUNT;
        $val['type'] = $type;
        if ($account != '' && !check_bankaccount($account)) {
            $error['account' . $idx] = trans('Incorrect bank account!');
        } elseif ($name && !$account) {
            $error['account' . $idx] = trans('Bank account is required!');
        } elseif ($account) {
            $contacts[] = array('name' => $name, 'contact' => $account, 'type' => $type);
        }
    }
}