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


PHP Entrepot::create方法代码示例

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


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

示例1: Entrepot

 * Actions
 */
// Ajout entrepot
if ($action == 'add' && $user->rights->stock->creer) {
    $object = new Entrepot($db);
    $object->ref = $_POST["ref"];
    $object->libelle = $_POST["libelle"];
    $object->description = $_POST["desc"];
    $object->statut = $_POST["statut"];
    $object->lieu = $_POST["lieu"];
    $object->address = $_POST["address"];
    $object->zip = $_POST["zipcode"];
    $object->town = $_POST["town"];
    $object->country_id = $_POST["country_id"];
    if ($object->libelle) {
        $id = $object->create($user);
        if ($id > 0) {
            header("Location: fiche.php?id=" . $id);
            exit;
        }
        $action = 'create';
        $mesg = '<div class="error">' . $object->error . '</div>';
    } else {
        $mesg = '<div class="error">' . $langs->trans("ErrorWarehouseRefRequired") . '</div>';
        $action = "create";
        // Force retour sur page creation
    }
}
// Delete warehouse
if ($action == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && $user->rights->stock->supprimer) {
    $object = new Entrepot($db);
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:31,代码来源:fiche.php

示例2: create

 /**
  *  Create a user into database
  *
  *  @param	User	$user        	Objet user doing creation
  *  @param  int		$notrigger		1=do not execute triggers, 0 otherwise
  *  @return int			         	<0 if KO, id of created user if OK
  */
 function create($user, $notrigger = 0)
 {
     global $conf, $langs;
     global $mysoc;
     // Clean parameters
     $this->login = trim($this->login);
     if (!isset($this->entity)) {
         $this->entity = $conf->entity;
     }
     // If not defined, we use default value
     dol_syslog(get_class($this) . "::create login=" . $this->login . ", user=" . (is_object($user) ? $user->id : ''), LOG_DEBUG);
     // Check parameters
     if (!empty($conf->global->USER_MAIL_REQUIRED) && !isValidEMail($this->email)) {
         $langs->load("errors");
         $this->error = $langs->trans("ErrorBadEMail", $this->email);
         return -1;
     }
     if (empty($this->login)) {
         $langs->load("errors");
         $this->error = $langs->trans("ErrorFieldRequired", $this->login);
         return -1;
     }
     $this->datec = dol_now();
     $error = 0;
     $this->db->begin();
     $sql = "SELECT login FROM " . MAIN_DB_PREFIX . "user";
     $sql .= " WHERE login ='" . $this->db->escape($this->login) . "'";
     $sql .= " AND entity IN (0," . $this->db->escape($conf->entity) . ")";
     dol_syslog(get_class($this) . "::create", LOG_DEBUG);
     $resql = $this->db->query($sql);
     if ($resql) {
         $num = $this->db->num_rows($resql);
         $this->db->free($resql);
         if ($num) {
             $this->error = 'ErrorLoginAlreadyExists';
             dol_syslog(get_class($this) . "::create " . $this->error, LOG_WARNING);
             $this->db->rollback();
             return -6;
         } else {
             $sql = "INSERT INTO " . MAIN_DB_PREFIX . "user (datec,login,ldap_sid,entity)";
             $sql .= " VALUES('" . $this->db->idate($this->datec) . "','" . $this->db->escape($this->login) . "','" . $this->db->escape($this->ldap_sid) . "'," . $this->db->escape($this->entity) . ")";
             $result = $this->db->query($sql);
             dol_syslog(get_class($this) . "::create", LOG_DEBUG);
             if ($result) {
                 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "user");
                 // Set default rights
                 if ($this->set_default_rights() < 0) {
                     $this->error = 'ErrorFailedToSetDefaultRightOfUser';
                     $this->db->rollback();
                     return -5;
                 }
                 // Update minor fields
                 $result = $this->update($user, 1, 1);
                 if ($result < 0) {
                     $this->db->rollback();
                     return -4;
                 }
                 if (!empty($conf->global->STOCK_USERSTOCK_AUTOCREATE)) {
                     require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
                     $langs->load("stocks");
                     $entrepot = new Entrepot($this->db);
                     $entrepot->libelle = $langs->trans("PersonalStock", $this->getFullName($langs));
                     $entrepot->description = $langs->trans("ThisWarehouseIsPersonalStock", $this->getFullName($langs));
                     $entrepot->statut = 1;
                     $entrepot->country_id = $mysoc->country_id;
                     $entrepot->create($user);
                 }
                 if (!$notrigger) {
                     // Call trigger
                     $result = $this->call_trigger('USER_CREATE', $user);
                     if ($result < 0) {
                         $error++;
                     }
                     // End call triggers
                 }
                 if (!$error) {
                     $this->db->commit();
                     return $this->id;
                 } else {
                     //$this->error=$interface->error;
                     dol_syslog(get_class($this) . "::create " . $this->error, LOG_ERR);
                     $this->db->rollback();
                     return -3;
                 }
             } else {
                 $this->error = $this->db->lasterror();
                 $this->db->rollback();
                 return -2;
             }
         }
     } else {
         $this->error = $this->db->lasterror();
         $this->db->rollback();
//.........这里部分代码省略.........
开发者ID:Samara94,项目名称:dolibarr,代码行数:101,代码来源:user.class.php

示例3: testMouvementCreate

 /**
  * testMouvementCreate
  *
  * @return	int
  */
 public function testMouvementCreate()
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     // We create a product for tests
     $product1 = new Product($db);
     $product1->initAsSpecimen();
     $product1->ref .= ' 1';
     $product1->label .= ' 1';
     $product1id = $product1->create($user);
     $product2 = new Product($db);
     $product2->initAsSpecimen();
     $product2->ref .= ' 2';
     $product2->label .= ' 2';
     $product2id = $product2->create($user);
     // We create a product for tests
     $warehouse1 = new Entrepot($db);
     $warehouse1->initAsSpecimen();
     $warehouse1->libelle .= ' 1';
     $warehouse1->description .= ' 1';
     $warehouse1id = $warehouse1->create($user);
     $warehouse2 = new Entrepot($db);
     $warehouse2->initAsSpecimen();
     $warehouse2->libelle .= ' 2';
     $warehouse2->description .= ' 2';
     $warehouse2id = $warehouse2->create($user);
     $localobject = new MouvementStock($this->savdb);
     // Do a list of movement into warehouse 1
     // Create an input movement (type = 3) of price 9.9 -> shoul dupdate PMP to 9.9
     $result = $localobject->_create($user, $product1id, $warehouse1id, 10, 3, 9.9, 'Movement for unit test 1', 'Inventory Code Test');
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertLessThan($result, 0);
     // Create an input movement (type = 3) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8
     $result = $localobject->_create($user, $product1id, $warehouse1id, 10, 3, 9.699999999999999, 'Movement for unit test 2', 'Inventory Code Test');
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertLessThan($result, 0);
     // Create an output movement (type = 2) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8
     $result = $localobject->_create($user, $product1id, $warehouse1id, -5, 2, 999, 'Movement for unit test 3', 'Inventory Code Test');
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertLessThan($result, 0);
     // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8
     $result = $localobject->_create($user, $product1id, $warehouse1id, 1, 0, 0, 'Input from transfer', 'Transfert X');
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertLessThan($result, 0);
     // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8
     $result = $localobject->_create($user, $product1id, $warehouse1id, -2, 1, 0, 'Output from transfer', 'Transfert Y');
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertLessThan($result, 0);
     // Do same but into warehouse 2
     // Create an input movement (type = 3) of price 9.9 -> shoul dupdate PMP to 9.9
     $result = $localobject->_create($user, $product1id, $warehouse2id, 10, 3, 9.9, 'Movement for unit test 1 wh 2', 'Inventory Code Test 2');
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertLessThan($result, 0);
     // Create an input movement (type = 3) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8
     $result = $localobject->_create($user, $product1id, $warehouse2id, 10, 3, 9.699999999999999, 'Movement for unit test 2 wh 2', 'Inventory Code Test 2');
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertLessThan($result, 0);
     // Create an output movement (type = 2) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8
     $result = $localobject->_create($user, $product1id, $warehouse2id, -5, 2, 999, 'Movement for unit test 3 wh 2', 'Inventory Code Test 2');
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertLessThan($result, 0);
     // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8
     $result = $localobject->_create($user, $product1id, $warehouse2id, 1, 0, 0, 'Input from transfer wh 2', 'Transfert X 2');
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertLessThan($result, 0);
     // Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8
     $result = $localobject->_create($user, $product1id, $warehouse2id, -2, 1, 0, 'Output from transfer wh 2', 'Transfert Y 2');
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertLessThan($result, 0);
     return $localobject;
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:79,代码来源:MouvementStockTest.php

示例4: testEntrepotCreate

 /**
  * testEntrepotCreate
  *
  * @return	void
  */
 public function testEntrepotCreate()
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     $localobject = new Entrepot($this->savdb);
     $localobject->initAsSpecimen();
     $result = $localobject->create($user);
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertLessThanOrEqual($result, 0);
     return $result;
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:19,代码来源:EntrepotTest.php

示例5: Entrepot

if ($_POST["action"] == 'add' && $user->rights->stock->creer)
{
	$entrepot = new Entrepot($db);

	$entrepot->ref         = $_POST["ref"];
	$entrepot->libelle     = $_POST["libelle"];
	$entrepot->description = $_POST["desc"];
	$entrepot->statut      = $_POST["statut"];
	$entrepot->lieu        = $_POST["lieu"];
	$entrepot->address     = $_POST["address"];
	$entrepot->cp          = $_POST["cp"];
	$entrepot->ville       = $_POST["ville"];
	$entrepot->pays_id     = $_POST["pays_id"];

	if ($entrepot->libelle) {
		$id = $entrepot->create($user);
		if ($id > 0)
		{
			header("Location: fiche.php?id=".$id);
			exit;
		}

		$_GET["action"] = 'create';
		$mesg="<div class='error'>".$entrepot->error."</div>";
	}
	else {
		$mesg="<div class='error'>".$langs->trans("ErrorWarehouseRefRequired")."</div>";
		$_GET["action"]="create";   // Force retour sur page cr�ation
	}
}
开发者ID:remyyounes,项目名称:dolibarr,代码行数:30,代码来源:fiche.php

示例6: create

	/**
	 *  Create a user into database
	 *  @param      user        	Objet user qui demande la creation
	 *  @param      notrigger		1 ne declenche pas les triggers, 0 sinon
	 *  @return     int         	<0 si KO, id compte cree si OK
	 */
	function create($user,$notrigger=0)
	{
		global $conf,$langs;

		// Clean parameters
		$this->login = trim($this->login);
		if (! isset($this->entity)) $this->entity=$conf->entity;	// If not defined, we use default value

		dol_syslog("User::Create login=".$this->login.", user=".(is_object($user)?$user->id:''), LOG_DEBUG);

		// Check parameters
		if (! empty($conf->global->USER_MAIL_REQUIRED) && ! isValidEMail($this->email))
		{
			$langs->load("errors");
			$this->error = $langs->trans("ErrorBadEMail",$this->email);
			return -1;
		}

		$now=dol_now();

		$error=0;
		$this->db->begin();

		$sql = "SELECT login FROM ".MAIN_DB_PREFIX."user";
		$sql.= " WHERE login ='".$this->db->escape($this->login)."'";
		$sql.= " AND entity IN (0,".$conf->entity.")";

		dol_syslog("User::Create sql=".$sql, LOG_DEBUG);
		$resql=$this->db->query($sql);
		if ($resql)
		{
			$num = $this->db->num_rows($resql);
			$this->db->free($resql);

			if ($num)
			{
				$this->error = 'ErrorLoginAlreadyExists';
				dol_syslog("User::Create ".$this->error, LOG_WARNING);
				$this->db->rollback();
				return -6;
			}
			else
			{
				$sql = "INSERT INTO ".MAIN_DB_PREFIX."user (datec,login,ldap_sid,entity)";
				$sql.= " VALUES('".$this->db->idate($now)."','".$this->db->escape($this->login)."','".$this->ldap_sid."',".$this->entity.")";
				$result=$this->db->query($sql);

				dol_syslog("User::Create sql=".$sql, LOG_DEBUG);
				if ($result)
				{
					$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."user");

					// Set default rights
					if ($this->set_default_rights() < 0)
					{
						$this->error=$this->db->error();
						$this->db->rollback();
						return -5;
					}

					// Update minor fields
					$result = $this->update($user,1,1);
					if ($result < 0)
					{
						$this->db->rollback();
						return -4;
					}

					if (! empty($conf->global->STOCK_USERSTOCK_AUTOCREATE))
					{
						require_once(DOL_DOCUMENT_ROOT."/product/stock/class/entrepot.class.php");
						$langs->load("stocks");
						$entrepot = new Entrepot($this->db);
						$entrepot->libelle = $langs->trans("PersonalStock",$this->nom);
						$entrepot->description = $langs->trans("ThisWarehouseIsPersonalStock",$this->prenom,$this->nom);
						$entrepot->statut = 1;
						$entrepot->create($user);
					}

					if (! $notrigger)
					{
						// Appel des triggers
						include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
						$interface = new Interfaces($this->db);
						$result = $interface->run_triggers('USER_CREATE',$this,$user,$langs,$conf);
						if ($result < 0) { $error++; $this->errors=$interface->errors; }
						// Fin appel triggers
					}

					if (! $error)
					{
						$this->db->commit();
						return $this->id;
					}
//.........这里部分代码省略.........
开发者ID:remyyounes,项目名称:dolibarr,代码行数:101,代码来源:user.class.php


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