コード例 #1
0
function write_customer($email, $name, $company, $address, $phone, $fax, $currency)
{
    global $paypal_sales_type_id, $paypal_tax_group_id, $paypal_salesman, $paypal_area, $paypal_location, $paypal_credit_status, $paypal_shipper;
    global $SysPrefs;
    log_message("Memory, write_customer start:" . memory_get_usage());
    $customer_id = find_customer_by_email($email);
    if (empty($customer_id)) {
        $customer_id = find_customer_by_name($company);
    }
    if (empty($customer_id)) {
        //it is a new customer
        begin_transaction();
        add_customer($company, substr($company, 0, 30), $address, '', $currency, 0, 0, $paypal_credit_status, -1, 0, 0, $SysPrefs->default_credit_limit(), $paypal_sales_type_id, 'PayPal');
        $customer_id = db_insert_id();
        add_branch($customer_id, $company, substr($company, 0, 30), $address, $paypal_salesman, $paypal_area, $paypal_tax_group_id, '', get_company_pref('default_sales_discount_act'), get_company_pref('debtors_act'), get_company_pref('default_prompt_payment_act'), $paypal_location, $address, 0, 0, $paypal_shipper, 'PayPal');
        $selected_branch = db_insert_id();
        $nameparts = explode(" ", $name);
        $firstname = "";
        for ($i = 0; $i < count($nameparts) - 1; $i++) {
            if (!empty($firstname)) {
                $firstname .= " ";
            }
            $firstname .= $nameparts[$i];
        }
        $lastname = $nameparts[count($nameparts) - 1];
        add_crm_person('paypal', $firstname, $lastname, $address, $phone, '', $fax, $email, '', '');
        add_crm_contact('customer', 'general', $selected_branch, db_insert_id());
        commit_transaction();
    } else {
        $selected_branch = 0;
    }
    log_message("Memory, write_customer end:" . memory_get_usage());
    return array($customer_id, $selected_branch);
}
コード例 #2
0
ファイル: customers.php プロジェクト: pthdnq/ivalley-svn
function handle_submit(&$selected_id)
{
    global $path_to_root, $Ajax, $auto_create_branch;
    if (!can_process()) {
        return;
    }
    if ($selected_id) {
        update_customer($_POST['customer_id'], $_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['tax_id'], $_POST['curr_code'], $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['credit_status'], $_POST['payment_terms'], input_num('discount') / 100, input_num('pymt_discount') / 100, input_num('credit_limit'), $_POST['sales_type'], $_POST['notes']);
        update_record_status($_POST['customer_id'], $_POST['inactive'], 'debtors_master', 'debtor_no');
        $Ajax->activate('customer_id');
        // in case of status change
        display_notification(_("Customer has been updated."));
    } else {
        //it is a new customer
        begin_transaction();
        add_customer($_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['tax_id'], $_POST['curr_code'], $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['credit_status'], $_POST['payment_terms'], input_num('discount') / 100, input_num('pymt_discount') / 100, input_num('credit_limit'), $_POST['sales_type'], $_POST['notes']);
        $selected_id = $_POST['customer_id'] = db_insert_id();
        if (isset($auto_create_branch) && $auto_create_branch == 1) {
            add_branch($selected_id, $_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['salesman'], $_POST['area'], $_POST['tax_group_id'], '', get_company_pref('default_sales_discount_act'), get_company_pref('debtors_act'), get_company_pref('default_prompt_payment_act'), $_POST['location'], $_POST['address'], 0, 0, $_POST['ship_via'], $_POST['notes']);
            $selected_branch = db_insert_id();
            add_crm_person($_POST['CustName'], $_POST['cust_ref'], '', $_POST['address'], $_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'], '', '');
            add_crm_contact('cust_branch', 'general', $selected_branch, db_insert_id());
        }
        commit_transaction();
        display_notification(_("A new customer has been added."));
        if (isset($auto_create_branch) && $auto_create_branch == 1) {
            display_notification(_("A default Branch has been automatically created, please check default Branch values by using link below."));
        }
        $Ajax->activate('_page_body');
    }
}
コード例 #3
0
 $result = db_query($sql, "could not find customer branch");
 if (db_num_rows($result) == 0) {
     if ($debug_sql) {
         display_notification("New Branch");
     }
     $debtor_no = $customer['debtor_no'];
     $sql = "SELECT * FROM " . TB_PREF . "cust_branch WHERE debtor_no = {$debtor_no}";
     if ($debug_sql) {
         display_notification("Find BR * " . $sql);
     }
     $result = db_query($sql, "could not find any customer branch");
     $old_branch = db_fetch_assoc($result);
     if ($debug_sql) {
         print_r($old_branch);
     }
     add_branch($debtor_no, $old_branch['br_name'], $old_braanch['branch_ref'], $addr, $old_branch['salesman'], $old_branch['area'], $taxgid, $old_branch['sales_account'], $old_branch['sales_discount_account'], $old_branch['receivables_account'], $old_branch['payment_discount_account'], $old_branch['default_location'], $addr, 0, 0, 1, $old_branch['notes']);
     $id = db_insert_id();
     $sql = "SELECT * FROM " . TB_PREF . "cust_branch WHERE branch_code = {$id}";
     if ($debug_sql) {
         display_notification("Get BR " . $sql);
     }
     $result = db_query($sql, "Could not load new branch");
 }
 $branch = db_fetch_assoc($result);
 // print_r($branch);
 // Now Add Sales_Order and Sales_Order_Details
 $cart = new Cart(30);
 // New Sales Order
 $cart->customer_id = $customer['debtor_no'];
 $cart->customer_currency = $customer['curr_code'];
 $cart->Branch = $branch['branch_code'];
コード例 #4
0
    }
    save($_SESSION['profiles_rights_file'], $rights);
    header('location:index.php?p=edit_profiles&token=' . TOKEN . '&msg=' . e('Changes saved', false));
    exit;
}
# Editor
if (isset($_POST['editor_content']) && !empty($_POST['editor_filename']) && is_allowed('markdown editor')) {
    $extension = pathinfo($_POST['editor_filename'], PATHINFO_EXTENSION);
    if (empty($extension)) {
        $_POST['editor_filename'] .= '.md';
    }
    $file = no_special_char($_POST['editor_filename']);
    $path = addslash_if_needed($_SESSION['upload_root_path'] . $_SESSION['upload_user_path'] . $_SESSION['current_path']);
    if (is_file($path . $file) && !isset($_POST['overwrite'])) {
        $file = rename_item($file, $path);
    }
    file_put_contents($path . $file, $_POST['editor_content']);
    if (!isset($_POST['overwrite'])) {
        $id = addID($path . $file);
        $tree = add_branch($path . $file, $id, $_SESSION['login'], $tree);
    }
    header('location:index.php?p=admin&token=' . TOKEN . '&msg=' . $_POST['editor_filename'] . ' ' . e('Changes saved', false));
    exit;
}
# Config change
if (isset($_POST['config']) && is_allowed('config page')) {
}
if ($_FILES && is_allowed('upload')) {
    include 'core/auto_dropzone.php';
    exit;
}
コード例 #5
0
ファイル: auto_dropzone.php プロジェクト: Pluxopolis/BoZoN
        } elseif ($sFileError) {
            // file upload error
            echo '<li class="DD_file DD_error"><span class="DD_filename">' . $sFileName . ': ' . $sFileError . ' </span></li>            ';
        } elseif (is_dir($_SESSION['upload_root_path'] . $_SESSION['upload_user_path'] . $auto_dropzone['destination_filepath'])) {
            $file = $sFileName;
            $sFileName = $auto_dropzone['destination_filepath'] . $sFileName;
            if (is_file($_SESSION['upload_root_path'] . $_SESSION['upload_user_path'] . $sFileName)) {
                $newfilename = rename_item($file, $_SESSION['upload_root_path'] . $_SESSION['upload_user_path'] . $auto_dropzone['destination_filepath']);
                echo '<li class="DD_file DD_warning"><span class="DD_filename">' . $file . ' => ' . $newfilename . ' </span></li>';
                $sFileName = $auto_dropzone['destination_filepath'] . $newfilename;
            }
            echo $ok;
            rename($_FILES['myfile']['tmp_name'], $_SESSION['upload_root_path'] . $_SESSION['upload_user_path'] . $sFileName);
            chmod($_SESSION['upload_root_path'] . $_SESSION['upload_user_path'] . $sFileName, 0644);
            $id = addID($_SESSION['upload_root_path'] . $_SESSION['upload_user_path'] . $sFileName);
            $tree = add_branch($_SESSION['upload_root_path'] . $_SESSION['upload_user_path'] . $sFileName, $id, $_SESSION['login'], $tree);
        }
    } else {
        echo $notok;
    }
    exit;
} else {
    // GENERATE DROPZONE
    if ($auto_dropzone['use_style']) {
        echo '
        <style>
            .DD_dropzone{
                font-family:courier;cursor:pointer;
                text-shadow:0 2px 1px white;
                box-sizing: border-box;
                text-align:center;
コード例 #6
0
        set_focus('br_name');
    }
    if (strlen($_POST['br_ref']) == 0) {
        $input_error = 1;
        display_error(_("The Branch short name cannot be empty."));
        set_focus('br_ref');
    }
    if ($input_error != 1) {
        begin_transaction();
        if ($selected_id != -1) {
            update_branch($_POST['customer_id'], $_POST['branch_code'], $_POST['br_name'], $_POST['br_ref'], $_POST['br_address'], $_POST['salesman'], $_POST['area'], $_POST['tax_group_id'], $_POST['sales_account'], $_POST['sales_discount_account'], $_POST['receivables_account'], $_POST['payment_discount_account'], $_POST['default_location'], $_POST['br_post_address'], $_POST['disable_trans'], $_POST['group_no'], $_POST['default_ship_via'], $_POST['notes']);
            //			update_record_status($_POST['supplier_id'], $_POST['inactive'],
            //				'cust_branch', 'branch_code');
            $note = _('Selected customer branch has been updated');
        } else {
            add_branch($_POST['customer_id'], $_POST['br_name'], $_POST['br_ref'], $_POST['br_address'], $_POST['salesman'], $_POST['area'], $_POST['tax_group_id'], $_POST['sales_account'], $_POST['sales_discount_account'], $_POST['receivables_account'], $_POST['payment_discount_account'], $_POST['default_location'], $_POST['br_post_address'], 0, $_POST['group_no'], $_POST['default_ship_via'], $_POST['notes']);
            $selected_id = db_insert_id();
            add_crm_person($_POST['contact_name'], $_POST['contact_name'], '', $_POST['br_post_address'], $_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'], $_POST['rep_lang'], '');
            add_crm_contact('cust_branch', 'general', $selected_id, db_insert_id());
            $note = _('New customer branch has been added');
        }
        commit_transaction();
        display_notification($note);
        //		$Mode = 'RESET';
        if (@$_REQUEST['popup']) {
            set_focus("Select" . ($_POST['branch_code'] == -1 ? $selected_id : $_POST['branch_code']));
        }
    }
} elseif ($Mode == 'Delete') {
    //the link to delete a selected record was clicked instead of the submit button
    // PREVENT DELETES IF DEPENDENT RECORDS IN 'debtor_trans'
コード例 #7
0
 public function post($rest)
 {
     $req = $rest->request();
     $info = $req->post();
     // Validate Required Fields
     if (!isset($info['custname'])) {
         api_error(412, 'Customer Name is required [custname]');
     }
     if (!isset($info['cust_ref'])) {
         api_error(412, 'Customer Reference is required [cust_ref]');
     }
     if (!isset($info['address'])) {
         api_error(412, 'Address is required [address]');
     }
     if (!isset($info['tax_id'])) {
         api_error(412, 'Tax Id is required [tax_id]');
     }
     if (!isset($info['curr_code'])) {
         api_error(412, 'Currency Code is required [curr_code]');
     }
     if (!isset($info['credit_status'])) {
         // TODO Set a default initial credit status
         api_error(412, 'Credit Status is required [credit_status]');
     }
     if (!isset($info['payment_terms'])) {
         api_error(412, 'Payment Terms is required [payment_terms]');
     }
     if (!isset($info['discount'])) {
         // TODO Set default discount as 0
         api_error(412, 'Discount is required [discount]');
     }
     if (!isset($info['pymt_discount'])) {
         // TODO Set default payment discount as 0
         api_error(412, 'Payment Discount is required [pymt_discount]');
     }
     if (!isset($info['credit_limit'])) {
         // TODO Set default credit limit from company configuration
         api_error(412, 'Credit Limit is required [credit_limit]');
     }
     if (!isset($info['sales_type'])) {
         api_error(412, 'Sales Type is required [sales_type]');
     }
     if (!isset($info['notes'])) {
         $info['notes'] = '';
     }
     // For default branch
     if (!isset($info['salesman'])) {
         $info['salesman'] = '';
     }
     if (!isset($info['area'])) {
         $info['area'] = '';
     }
     if (!isset($info['tax_group_id'])) {
         $info['tax_group_id'] = '1';
     }
     if (!isset($info['location'])) {
         $info['location'] = '1';
     }
     if (!isset($info['ship_via'])) {
         $info['ship_via'] = '1';
     }
     if (!isset($info['phone'])) {
         $info['phone'] = '';
     }
     if (!isset($info['phone2'])) {
         $info['phone2'] = '';
     }
     if (!isset($info['fax'])) {
         $info['fax'] = '';
     }
     if (!isset($info['email'])) {
         $info['email'] = '';
     }
     /*
      * $CustName, $cust_ref, $address, $tax_id, $curr_code, $dimension_id, $dimension2_id, $credit_status,
      * $payment_terms, $discount, $pymt_discount, $credit_limit, $sales_type, $notes
      */
     add_customer($info['custname'], $info['cust_ref'], $info['address'], $info['tax_id'], $info['curr_code'], 0, 0, $info['credit_status'], $info['payment_terms'], $info['discount'], $info['pymt_discount'], $info['credit_limit'], $info['sales_type'], $info['notes']);
     $selected_id = db_insert_id();
     $auto_create_branch = 1;
     if (isset($auto_create_branch) && $auto_create_branch == 1) {
         add_branch($selected_id, $info['custname'], $info['cust_ref'], $info['address'], $info['salesman'], $info['area'], $info['tax_group_id'], '1', get_company_pref('default_sales_discount_act'), get_company_pref('debtors_act'), get_company_pref('default_prompt_payment_act'), $info['location'], $info['address'], 0, 0, $info['ship_via'], $info['notes']);
         $selected_branch = db_insert_id();
         add_crm_person($info['cust_ref'], $info['custname'], '', $info['address'], $info['phone'], $info['phone2'], $info['fax'], $info['email'], '', '');
         $pers_id = db_insert_id();
         add_crm_contact('cust_branch', 'general', $selected_branch, $pers_id);
         add_crm_contact('customer', 'general', $selected_id, $pers_id);
     }
     $cust = get_customer($selected_id);
     if ($cust != null) {
         api_create_response(json_encode($cust));
     } else {
         api_error(500, 'Could Not Save to Database');
     }
 }