当前位置: 首页>>代码示例>>PHP>>正文


PHP Societe::create_individual方法代码示例

本文整理汇总了PHP中Societe::create_individual方法的典型用法代码示例。如果您正苦于以下问题:PHP Societe::create_individual方法的具体用法?PHP Societe::create_individual怎么用?PHP Societe::create_individual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Societe的用法示例。


在下文中一共展示了Societe::create_individual方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createThirdParty

/**
 * Create a thirdparty
 *
 * @param	array		$authentication		Array of authentication information
 * @param	Societe		$thirdparty		    Thirdparty
 * @return	array							Array result
 */
function createThirdParty($authentication, $thirdparty)
{
    global $db, $conf, $langs;
    $now = dol_now();
    dol_syslog("Function: createThirdParty login=" . $authentication['login']);
    if ($authentication['entity']) {
        $conf->entity = $authentication['entity'];
    }
    // Init and check authentication
    $objectresp = array();
    $errorcode = '';
    $errorlabel = '';
    $error = 0;
    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
    // Check parameters
    if (empty($thirdparty['ref'])) {
        $error++;
        $errorcode = 'KO';
        $errorlabel = "Name is mandatory.";
    }
    if (!$error) {
        include_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
        $newobject = new Societe($db);
        $newobject->ref = $thirdparty['ref'];
        $newobject->name = $thirdparty['ref'];
        $newobject->ref_ext = $thirdparty['ref_ext'];
        $newobject->status = $thirdparty['status'];
        $newobject->client = $thirdparty['client'];
        $newobject->fournisseur = $thirdparty['supplier'];
        $newobject->code_client = $thirdparty['customer_code'];
        $newobject->code_fournisseur = $thirdparty['supplier_code'];
        $newobject->code_compta = $thirdparty['customer_code_accountancy'];
        $newobject->code_compta_fournisseur = $thirdparty['supplier_code_accountancy'];
        $newobject->date_creation = $now;
        $newobject->note_private = $thirdparty['note_private'];
        $newobject->note_public = $thirdparty['note_public'];
        $newobject->address = $thirdparty['address'];
        $newobject->zip = $thirdparty['zip'];
        $newobject->town = $thirdparty['town'];
        $newobject->country_id = $thirdparty['country_id'];
        if ($thirdparty['country_code']) {
            $newobject->country_id = getCountry($thirdparty['country_code'], 3);
        }
        $newobject->province_id = $thirdparty['province_id'];
        //if ($thirdparty['province_code']) $newobject->province_code=getCountry($thirdparty['province_code'],3);
        $newobject->phone = $thirdparty['phone'];
        $newobject->fax = $thirdparty['fax'];
        $newobject->email = $thirdparty['email'];
        $newobject->url = $thirdparty['url'];
        $newobject->idprof1 = $thirdparty['profid1'];
        $newobject->idprof2 = $thirdparty['profid2'];
        $newobject->idprof3 = $thirdparty['profid3'];
        $newobject->idprof4 = $thirdparty['profid4'];
        $newobject->idprof5 = $thirdparty['profid5'];
        $newobject->idprof6 = $thirdparty['profid6'];
        $newobject->capital = $thirdparty['capital'];
        $newobject->barcode = $thirdparty['barcode'];
        $newobject->tva_assuj = $thirdparty['vat_used'];
        $newobject->tva_intra = $thirdparty['vat_number'];
        $newobject->canvas = $thirdparty['canvas'];
        $newobject->particulier = $thirdparty['individual'];
        //Retreive all extrafield for thirdsparty
        // fetch optionals attributes and labels
        $extrafields = new ExtraFields($db);
        $extralabels = $extrafields->fetch_name_optionals_label('societe', true);
        foreach ($extrafields->attribute_label as $key => $label) {
            $key = 'options_' . $key;
            $newobject->array_options[$key] = $thirdparty[$key];
        }
        $db->begin();
        $result = $newobject->create($fuser);
        if ($newobject->particulier && $result > 0) {
            $newobject->firstname = $thirdparty['firstname'];
            $newobject->name_bis = $thirdparty['lastname'];
            $result = $newobject->create_individual($fuser);
        }
        if ($result <= 0) {
            $error++;
        }
        if (!$error) {
            $db->commit();
            // Patch to add capability to associate (one) sale representative
            if ($thirdparty['commid'] && $thirdparty['commid'] > 0) {
                $newobject->add_commercial($fuser, $thirdparty["commid"]);
            }
            $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $newobject->id, 'ref' => $newobject->ref);
        } else {
            $db->rollback();
            $error++;
            $errorcode = 'KO';
            $errorlabel = $newobject->error;
        }
    }
//.........这里部分代码省略.........
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:101,代码来源:server_thirdparty.php


注:本文中的Societe::create_individual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。