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


PHP Societe::create方法代码示例

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


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

示例1: post

 /**
  * Create thirdparty object
  *
  * @param array $request_data   Request datas
  * @return int  ID of thirdparty
  * 
  * @url	POST thirdparty/
  */
 function post($request_data = NULL)
 {
     if (!DolibarrApiAccess::$user->rights->societe->creer) {
         throw new RestException(401);
     }
     // Check mandatory fields
     $result = $this->_validate($request_data);
     foreach ($request_data as $field => $value) {
         $this->company->{$field} = $value;
     }
     return $this->company->create(DolibarrApiAccess::$user);
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:20,代码来源:api_thirdparty.class.php

示例2: 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

示例3: 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=$thirdparty['note'];
        $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'];

        $db->begin();

        $result=$newobject->create($fuser);
        if ($result <= 0)
        {
            $error++;
        }

        if (! $error)
        {
            $db->commit();
            $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
        }
        else
        {
            $db->rollback();
            $error++;
            $errorcode='KO';
            $errorlabel=$newobject->error;
        }
    }

    if ($error)
    {
        $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
    }
//.........这里部分代码省略.........
开发者ID:nrjacker4,项目名称:crm-php,代码行数:101,代码来源:server_thirdparty.php

示例4: createUserFromThirdparty

/**
 * Create an external user with thirdparty and contact
 *
 * @param	array		$authentication		Array of authentication information
 * @param	array		$thirdpartywithuser Datas
 * @return	mixed
 */
function createUserFromThirdparty($authentication, $thirdpartywithuser)
{
    global $db, $conf, $langs;
    dol_syslog("Function: createUserFromThirdparty login=" . $authentication['login'] . " id=" . $id . " ref=" . $ref . " ref_ext=" . $ref_ext);
    if ($authentication['entity']) {
        $conf->entity = $authentication['entity'];
    }
    $objectresp = array();
    $errorcode = '';
    $errorlabel = '';
    $error = 0;
    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
    if ($fuser->societe_id) {
        $socid = $fuser->societe_id;
    }
    if (!$error && !$thirdpartywithuser) {
        $error++;
        $errorcode = 'BAD_PARAMETERS';
        $errorlabel = "Parameter thirdparty must be provided.";
    }
    if (!$error) {
        $fuser->getrights();
        if ($fuser->rights->societe->creer) {
            $thirdparty = new Societe($db);
            // If a contact / company already exists with the email, return the corresponding socid
            $sql = "SELECT s.rowid as societe_id FROM " . MAIN_DB_PREFIX . "societe as s";
            $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople as sp ON sp.fk_soc = s.rowid";
            $sql .= " WHERE s.entity=" . $conf->entity;
            $sql .= " AND s.email='" . $db->escape($thirdpartywithuser['email']) . "'";
            $sql .= " OR sp.email='" . $db->escape($thirdpartywithuser['email']) . "'";
            $sql .= $db->plimit(1);
            $resql = $db->query($sql);
            if ($resql) {
                // If a company or contact is found with the same email we return an error
                $row = $db->fetch_object($resql);
                if ($row) {
                    $error++;
                    $errorcode = 'ALREADY_EXIST';
                    $errorlabel = 'Object not create : company or contact exists ' . $thirdpartywithuser['email'];
                } else {
                    $db->begin();
                    /*
                     * Company creation
                     */
                    $thirdparty->name = $thirdpartywithuser['name_thirdparty'];
                    $thirdparty->ref_ext = $thirdpartywithuser['ref_ext'];
                    $thirdparty->address = $thirdpartywithuser['address'];
                    $thirdparty->zip = $thirdpartywithuser['zip'];
                    $thirdparty->town = $thirdpartywithuser['town'];
                    $thirdparty->country_id = $thirdpartywithuser['country_id'];
                    $thirdparty->country_code = $thirdpartywithuser['country_code'];
                    // find the country id by code
                    $langs->load("dict");
                    $sql = "SELECT rowid";
                    $sql .= " FROM " . MAIN_DB_PREFIX . "c_pays";
                    $sql .= " WHERE active = 1";
                    $sql .= " AND code='" . $thirdparty->country_code . "'";
                    $resql = $db->query($sql);
                    if ($resql) {
                        $num = $db->num_rows($resql);
                        if ($num) {
                            $obj = $db->fetch_object($resql);
                            $thirdparty->country_id = $obj->rowid;
                        }
                    }
                    $thirdparty->phone = $thirdpartywithuser['phone'];
                    $thirdparty->fax = $thirdpartywithuser['fax'];
                    $thirdparty->email = $thirdpartywithuser['email'];
                    $thirdparty->url = $thirdpartywithuser['url'];
                    $thirdparty->ape = $thirdpartywithuser['ape'];
                    $thirdparty->idprof1 = $thirdpartywithuser['prof1'];
                    $thirdparty->idprof2 = $thirdpartywithuser['prof2'];
                    $thirdparty->idprof3 = $thirdpartywithuser['prof3'];
                    $thirdparty->idprof4 = $thirdpartywithuser['prof4'];
                    $thirdparty->idprof5 = $thirdpartywithuser['prof5'];
                    $thirdparty->idprof6 = $thirdpartywithuser['prof6'];
                    $thirdparty->client = $thirdpartywithuser['client'];
                    $thirdparty->fournisseur = $thirdpartywithuser['fournisseur'];
                    $socid_return = $thirdparty->create($fuser);
                    if ($socid_return > 0) {
                        $thirdparty->fetch($socid_return);
                        /*
                         * Contact creation
                         *
                         */
                        $contact = new Contact($db);
                        $contact->socid = $thirdparty->id;
                        $contact->lastname = $thirdpartywithuser['name'];
                        $contact->firstname = $thirdpartywithuser['firstname'];
                        $contact->civility_id = $thirdparty->civility_id;
                        $contact->address = $thirdparty->address;
                        $contact->zip = $thirdparty->zip;
                        $contact->town = $thirdparty->town;
//.........这里部分代码省略.........
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:101,代码来源:server_user.php

示例5: create

	/**
     *    Create third party in database
     *    @param      user        Object of user that ask creation
     *    @return     int         >= 0 if OK, < 0 if KO
     */
    function create($user='')
    {
    	$result = parent::create($user);

		return $result;
    }
开发者ID:remyyounes,项目名称:dolibarr,代码行数:11,代码来源:dao_thirdparty_default.class.php

示例6: Societe

 /**
  * Constructor
  * We save global variables into local variables
  *
  * @return DateLibTest
  */
 function __construct()
 {
     //$this->sharedFixture
     global $conf, $user, $langs, $db;
     $this->savconf = $conf;
     $this->savuser = $user;
     $this->savlangs = $langs;
     $this->savdb = $db;
     $WS_DOL_URL = DOL_MAIN_URL_ROOT . '/webservices/server_invoice.php';
     // Set the WebService URL
     print __METHOD__ . " create nusoap_client for URL=" . $WS_DOL_URL . "\n";
     $this->soapclient = new nusoap_client($WS_DOL_URL);
     if ($this->soapclient) {
         $this->soapclient->soap_defencoding = 'UTF-8';
         $this->soapclient->decodeUTF8(false);
     }
     // create a third_party, needed to create an invoice
     $societe = new Societe($db);
     $societe->ref = '';
     $societe->name = 'name';
     $societe->ref_ext = '209';
     $societe->status = 1;
     $societe->client = 1;
     $societe->fournisseur = 0;
     $societe->date_creation = $now;
     $societe->tva_assuj = 0;
     $societe->particulier = 0;
     $societe->create($user);
     $this->socid = $societe->id;
     print __METHOD__ . " societe created id=" . $societe->id . "\n";
     print __METHOD__ . " db->type=" . $db->type . " user->id=" . $user->id;
     //print " - db ".$db->db;
     print "\n";
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:40,代码来源:WebservicesInvoicesTest.php

示例7: Societe

    print "Company $s\n";
    $soc = new Societe($db);
    $soc->nom = "Company num ".time()."$s";
    $soc->ville = $villes[rand(0,sizeof($villes)-1)];
    $soc->client = rand(1,2);		// Une societe sur 2 est prospect, l'autre client
    $soc->fournisseur = rand(0,1);	// Une societe sur 2 est fournisseur
    $soc->code_client='CU'.time()."$s";
    $soc->code_fournisseur='SU'.time()."$s";
    $soc->tva_assuj=1;
    $soc->pays_id=1;
    $soc->pays_code='FR';
	// Un client sur 3 a une remise de 5%
    $user_remise=rand(1,3); if ($user_remise==3) $soc->remise_client=5;
	print "> client=".$soc->client.", fournisseur=".$soc->fournisseur.", remise=".$soc->remise_client."\n";
	$soc->note='Company created by the script generate-societe.php';
    $socid = $soc->create();

    if ($socid >= 0)
    {
        $rand = rand(1,4);
        print "> Generates $rand contact(s)\n";
        for ($c = 0 ; $c < $rand ; $c++)
        {
            $contact = new Contact($db);
            $contact->socid = $soc->id;
            $contact->name = "Lastname".$c;
            $contact->firstname = $prenoms[rand(0,sizeof($prenoms)-1)];
            if ( $contact->create($user) )
            {

            }
开发者ID:remyyounes,项目名称:dolibarr,代码行数:31,代码来源:generate-societe.php

示例8: switch


//.........这里部分代码省略.........
                         }
                         if (!empty($ligne[5])) {
                             $doliprod->tva_tx = $ligne[5];
                         }
                         if (!empty($ligne[6])) {
                             $doliprod->weight = $ligne[6];
                         }
                         if (!empty($ligne[7])) {
                             $doliprod->volume = $ligne[7];
                         }
                         if (!empty($ligne[9])) {
                             $doliprod->barcode = $ligne[9];
                         }
                         if (!empty($ligne[9])) {
                             $doliprod->barcode_type = dol_getIdFromCode($this->db, $ligne[10], 'c_barcode_type', 'libelle', 'rowid');
                         }
                         if (!empty($ligne[10])) {
                             $doliprod->type = $ligne[11];
                         }
                         $doliprod->price_base_type = 'HT';
                         $this->db->begin;
                         switch ($typeimport) {
                             case 'C':
                                 if ($pid > 0) {
                                     if ($doliprod->update($pid, $this->user) < 0) {
                                         $this->process_msg .= $langs->trans("ErrProductUpdate", $ligne[0], $doliprod->error) . "\n";
                                         $error++;
                                     }
                                     if ($doliprod->updatePrice($doliprod->price, $doliprod->price_base_type, $this->user) < 0) {
                                         $this->process_msg .= $langs->trans("ErrProductUpdate", $ligne[0], $doliprod->error) . "\n";
                                         $error++;
                                     }
                                 } else {
                                     if ($doliprod->create($this->user) < 0) {
                                         $this->process_msg .= $langs->trans("ErrProductCreate", $ligne[0], $doliprod->error) . "\n";
                                         $error++;
                                     } else {
                                         // image et code barre
                                         if ($ligne[8]) {
                                             $this->add_photo_web($conf->produit->dir_output, $ligne[8], $doliprod->id);
                                         }
                                         /*if ($ligne[9]) {
                                         			if ($doliprod->setValueFrom('fk_barcode_type', 2) < 0){
                                         				$this->process_msg .= $langs->trans("ErrProductCreate", $ligne[0], $doliprod->error)."\n"; // TODO paramétrer
                                         				$error++;
                                         			}
                                         			if ($doliprod->setValueFrom('barcode', $ligne[9]) < 0 ){
                                         				$this->process_msg .= $langs->trans("ErrProductCreate", $ligne[0], $doliprod->error)."\n";
                                         				$error++;
                                         			}
                                         		}*/
                                     }
                                 }
                                 break;
                                 /*case 'M':
                                 		if ($pid>0) 
                                 		{
                                 			if ($doliprod->update($pid, $this->user) < 0){
                                 				$this->process_msg .= $langs->trans("ErrProductUpdate", $ligne[0], $doliprod->error)."\n";
                                 				$error++;
                                 			}
                                 			if (version_compare(DOL_VERSION, 3.5) >= 0){
                                 				if ($doliprod->updatePrice($doliprod->price, $doliprod->price_base_type, $this->user) < 0){
                                 					$this->process_msg .= $langs->trans("ErrProductUpdate", $ligne[0], $doliprod->error)."\n";
                                 					$error++;
                                 				}
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:67,代码来源:importator.class.php

示例9: _createTiers

function _createTiers(&$db, &$user, &$ad)
{
    $societe = new Societe($db);
    $name = trim($ad->firstname . ' ' . $ad->lastname);
    if (!empty($name)) {
        $name .= ' / ' . $ad->societe;
    } else {
        $name = $ad->societe;
    }
    $societe->name = $name;
    $societe->client = 1;
    if (!empty($ad->email) && isValidEMail($ad->email)) {
        $societe->email = $ad->email;
    }
    $societe->address = $ad->address;
    $societe->zip = $ad->zip;
    $societe->town = $ad->town;
    $societe->state_id = $ad->state_id;
    $societe->country_id = $ad->country_id;
    $societe->phone = $ad->phone;
    if ($societe->create($user) > 0) {
        $ad->fk_soc = $societe->id;
        return $societe;
    } else {
        return false;
    }
}
开发者ID:ATM-Consulting,项目名称:dolibarr_module_sendinvoicetoadherent,代码行数:27,代码来源:sendinvoicetoadherent.php

示例10: testSocieteCreate

    /**
     * testSocieteCreate
     *
     * @return int
     */
    public function testSocieteCreate()
    {
    	global $conf,$user,$langs,$db;
		$conf=$this->savconf;
		$user=$this->savuser;
		$langs=$this->savlangs;
		$db=$this->savdb;

		$localobject=new Societe($this->savdb);
    	$localobject->initAsSpecimen();
    	$result=$localobject->create($user);

        print __METHOD__." result=".$result."\n";
    	$this->assertLessThanOrEqual($result, 0);

    	return $result;
    }
开发者ID:nrjacker4,项目名称:crm-php,代码行数:22,代码来源:SocieteTest.php

示例11: testAdherentSetThirdPartyId

 /**
  * testAdherentSetThirdPartyId
  *
  * @param   Adherent    $localobject    Member instance
  * @return  Adherent
  *
  * @depends testAdherentSetUserId
  * The depends says test is run only if previous is ok
  */
 public function testAdherentSetThirdPartyId(Adherent $localobject)
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     //Create a Third Party
     $thirdparty = new Societe($db);
     $thirdparty->initAsSpecimen();
     $result = $thirdparty->create($user);
     print __METHOD__ . " id=" . $localobject->id . " third party id=" . $thirdparty->id . " result=" . $result . "\n";
     $this->assertTrue($result > 0);
     //Set Third Party ID
     $result = $localobject->setThirdPartyId($thirdparty->id);
     $this->assertEquals($result, 1);
     print __METHOD__ . " id=" . $localobject->id . " result=" . $result . "\n";
     //Adherent is updated with new data
     $localobject->fetch($localobject->id);
     $this->assertEquals($localobject->fk_soc, $thirdparty->id);
     print __METHOD__ . " id=" . $localobject->id . " result=" . $result . "\n";
     //We remove the third party association
     $result = $localobject->setThirdPartyId(0);
     $this->assertEquals($result, 1);
     //And check if it has been updated
     $localobject->fetch($localobject->id);
     $this->assertNull($localobject->fk_soc);
     //Now we remove the third party
     $result = $thirdparty->delete($thirdparty->id, $user);
     $this->assertEquals($result, 1);
     return $localobject;
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:41,代码来源:AdherentTest.php


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