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


PHP Categorie::add_type方法代码示例

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


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

示例1: setCategories

 /**
  * Sets object to supplied categories.
  *
  * Deletes object from existing categories not supplied.
  * Adds it to non existing supplied categories.
  * Existing categories are left untouch.
  *
  * @param int[]|int $categories Category or categories IDs
  */
 public function setCategories($categories)
 {
     // Handle single category
     if (!is_array($categories)) {
         $categories = array($categories);
     }
     // Get current categories
     require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
     $c = new Categorie($this->db);
     $existing = $c->containing($this->id, Categorie::TYPE_PRODUCT, 'id');
     // Diff
     if (is_array($existing)) {
         $to_del = array_diff($existing, $categories);
         $to_add = array_diff($categories, $existing);
     } else {
         $to_del = array();
         // Nothing to delete
         $to_add = $categories;
     }
     // Process
     foreach ($to_del as $del) {
         $c->fetch($del);
         $c->del_type($this, 'product');
     }
     foreach ($to_add as $add) {
         $c->fetch($add);
         $c->add_type($this, 'product');
     }
     return;
 }
开发者ID:TAASA,项目名称:Dolibarr-ERP-3.8.1,代码行数:39,代码来源:product.class.php

示例2: header

}
if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confirm == 'yes') {
    if ($object->delete($user) >= 0) {
        header("Location: " . DOL_URL_ROOT . '/categories/index.php?type=' . $type);
        exit;
    } else {
        setEventMessages($object->error, $object->errors, 'errors');
    }
}
if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory' && ($user->rights->produit->creer || $user->rights->service->creer)) {
    require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
    $newobject = new Product($db);
    $result = $newobject->fetch($elemid);
    $elementtype = 'product';
    // TODO Add into categ
    $result = $object->add_type($newobject, $elementtype);
    if ($result >= 0) {
        setEventMessages($langs->trans("WasAddedSuccessfully", $newobject->ref), null, 'mesgs');
    } else {
        if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
            setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
        } else {
            setEventMessages($object->error, $object->errors, 'errors');
        }
    }
}
/*
 * View
 */
$form = new Form($db);
$formother = new FormOther($db);
开发者ID:Samara94,项目名称:dolibarr,代码行数:31,代码来源:viewcat.php

示例3: elseif

 /**
  * Link an object to the category
  *
  * @param   CommonObject $obj  Object to link to category
  * @param   string       $type Type of category ('customer', 'supplier', 'contact', 'product', 'member')
  *
  * @return  int                1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked
  */
 function add_type($obj, $type)
 {
     global $user, $langs, $conf;
     $error = 0;
     if ($this->id == -1) {
         return -2;
     }
     // For backward compatibility
     if ($type == 'societe') {
         $type = 'customer';
         dol_syslog(get_class($this) . "::add_type(): type 'societe' is deprecated, please use 'customer' instead", LOG_WARNING);
     } elseif ($type == 'fournisseur') {
         $type = 'supplier';
         dol_syslog(get_class($this) . "::add_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", LOG_WARNING);
     }
     $this->db->begin();
     $sql = "INSERT INTO " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type];
     $sql .= " (fk_categorie, fk_" . $this->MAP_CAT_FK[$type] . ")";
     $sql .= " VALUES (" . $this->id . ", " . $obj->id . ")";
     dol_syslog(get_class($this) . '::add_type', LOG_DEBUG);
     if ($this->db->query($sql)) {
         if (!empty($conf->global->CATEGORIE_RECURSIV_ADD)) {
             $sql = 'SELECT fk_parent FROM ' . MAIN_DB_PREFIX . 'categorie';
             $sql .= " WHERE rowid = " . $this->id;
             dol_syslog(get_class($this) . "::add_type", LOG_DEBUG);
             $resql = $this->db->query($sql);
             if ($resql) {
                 if ($this->db->num_rows($resql) > 0) {
                     $objparent = $this->db->fetch_object($resql);
                     if (!empty($objparent->fk_parent)) {
                         $cat = new Categorie($this->db);
                         $cat->id = $objparent->fk_parent;
                         $result = $cat->add_type($obj, $type);
                         if ($result < 0) {
                             $this->error = $cat->error;
                             $error++;
                         }
                     }
                 }
             } else {
                 $error++;
                 $this->error = $this->db->lasterror();
             }
             if ($error) {
                 $this->db->rollback();
                 return -1;
             }
         }
         // Save object we want to link category to into category instance to provide information to trigger
         $this->linkto = $obj;
         // Call trigger
         $result = $this->call_trigger('CATEGORY_LINK', $user);
         if ($result < 0) {
             $error++;
         }
         // End call triggers
         if (!$error) {
             $this->db->commit();
             return 1;
         } else {
             $this->db->rollback();
             return -2;
         }
     } else {
         $this->db->rollback();
         if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
             $this->error = $this->db->lasterrno();
             return -3;
         } else {
             $this->error = $this->db->lasterror();
         }
         return -1;
     }
 }
开发者ID:TAASA,项目名称:Dolibarr-ERP-3.8.1,代码行数:82,代码来源:categorie.class.php

示例4: create


//.........这里部分代码省略.........
				$sql.= ", ".price2num($price_min_ht);
				$sql.= ", ".price2num($price_min_ttc);
				$sql.= ", ".($this->libelle?"'".$this->db->escape($this->libelle)."'":"null");
				$sql.= ", ".$user->id;
				$sql.= ", ".$this->type;
				$sql.= ", ".price2num($price_ht);
				$sql.= ", ".price2num($price_ttc);
				$sql.= ", '".$this->price_base_type."'";
				$sql.= ", ".$this->status;
				$sql.= ", ".$this->status_buy;
				$sql.= ", '".$this->canvas."'";
				$sql.= ", ".$this->finished;
                                $sql.= ", ".price2num($ecotax_ht);
                                $sql.= ", ".price2num($ecotax_ttc);
				$sql.= ")";

				dol_syslog(get_class($this)."::Create sql=".$sql);
				$result = $this->db->query($sql);
				if ( $result )
				{
					$id = $this->db->last_insert_id(MAIN_DB_PREFIX."product");

					if ($id > 0)
					{
						$this->id				= $id;
						$this->price			= $price_ht;
						$this->price_ttc		= $price_ttc;
						$this->price_min		= $price_min_ht;
						$this->price_min_ttc	= $price_min_ttc;

						$result = $this->_log_price($user);
						if ($result > 0)
						{
							if ($this->update($id, $user, true) > 0)
							{
								if ($this->catid > 0)
								{
									require_once(DOL_DOCUMENT_ROOT ."/categories/class/categorie.class.php");
									$cat = new Categorie($this->db, $this->catid);
									$cat->add_type($this,"product");
								}
							}
							else
							{
							    $error++;
					            $this->error='ErrorFailedToUpdateRecord';
							}
						}
						else
						{
							$error++;
						    $this->error=$this->db->lasterror();
						}
					}
					else
					{
						$error++;
					    $this->error='ErrorFailedToGetInsertedId';
					}
				}
				else
				{
					$error++;
				    $this->error=$this->db->lasterror();
				}
			}
			else
			{
				// Product already exists with this ref
				$langs->load("products");
				$this->error = "ErrorProductAlreadyExists";
			}
		}
		else
		{
			$error++;
		    $this->error=$this->db->lasterror();
		}

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

		if (! $error)
		{
			$this->db->commit();
			return $this->id;
		}
		else
		{
			$this->db->rollback();
			return -$error;
		}
	}
开发者ID:nrjacker4,项目名称:crm-php,代码行数:101,代码来源:product.class.php

示例5: setCategories

	/**
	 * Sets object to supplied categories.
	 *
	 * Deletes object from existing categories not supplied.
	 * Adds it to non existing supplied categories.
	 * Existing categories are left untouch.
	 *
	 * @param int[]|int $categories Category or categories IDs
	 * @param string $type Category type (customer or supplier)
	 */
	public function setCategories($categories, $type)
	{
		// Decode type
		if ($type == 'customer') {
			$type_id = Categorie::TYPE_CUSTOMER;
			$type_text = 'customer';
		} elseif ($type == 'supplier') {
			$type_id = Categorie::TYPE_SUPPLIER;
			$type_text = 'supplier';
		} else {
			dol_syslog(__METHOD__ . ': Type ' . $type .  'is an unknown company category type. Done nothing.', LOG_ERR);
			return;
		}

		// Handle single category
		if (!is_array($categories)) {
			$categories = array($categories);
		}

		// Get current categories
		require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
		$c = new Categorie($this->db);
		$existing = $c->containing($this->id, $type_id, 'id');

		// Diff
		if (is_array($existing)) {
			$to_del = array_diff($existing, $categories);
			$to_add = array_diff($categories, $existing);
		} else {
			$to_del = array(); // Nothing to delete
			$to_add = $categories;
		}

		// Process
		foreach ($to_del as $del) {
			if ($c->fetch($del) > 0) {
				$c->del_type($this, $type_text);
			}
		}
		foreach ($to_add as $add) {
			if ($c->fetch($add) > 0) {
				$c->add_type($this, $type_text);
			}
		}

		return;
	}
开发者ID:NoisyBoy86,项目名称:Dolibarr_test,代码行数:57,代码来源:societe.class.php

示例6: Adherent

        }
        if ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) {
            require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
            $object = new Adherent($db);
            $result = $object->fetch($objectid);
            $elementtype = 'member';
        }
        if ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) {
            require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
            $object = new Contact($db);
            $result = $object->fetch($objectid);
            $elementtype = 'contact';
        }
        $cat = new Categorie($db);
        $result = $cat->fetch($parent);
        $result = $cat->add_type($object, $elementtype);
        if ($result >= 0) {
            setEventMessages($langs->trans("WasAddedSuccessfully", $cat->label), null, 'mesgs');
        } else {
            if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
                setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
            } else {
                setEventMessages($cat->error, $cat->errors, 'errors');
            }
        }
    }
}
/*
 *	View
 */
$form = new Form($db);
开发者ID:Albertopf,项目名称:prueba,代码行数:31,代码来源:categorie.php

示例7: VALUES

 /**
  * 	Link an object to the category
  *
  *	@param		Object	$obj	Object to link to category
  * 	@param		string	$type	Type of category ('member', 'customer', 'supplier', 'product', 'contact')
  * 	@return		int				1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked
  */
 function add_type($obj, $type)
 {
     global $user, $langs, $conf;
     $error = 0;
     if ($this->id == -1) {
         return -2;
     }
     // For backward compatibility
     if ($type == 'company') {
         $type = 'societe';
     }
     if ($type == 'customer') {
         $type = 'societe';
     }
     if ($type == 'supplier') {
         $type = 'fournisseur';
     }
     $column_name = $type;
     if ($type == 'contact') {
         $column_name = 'socpeople';
     }
     if ($type == 'fournisseur') {
         $column_name = 'societe';
     }
     $sql = "INSERT INTO " . MAIN_DB_PREFIX . "categorie_" . $type . " (fk_categorie, fk_" . $column_name . ")";
     $sql .= " VALUES (" . $this->id . ", " . $obj->id . ")";
     dol_syslog(get_class($this) . '::add_type sql=' . $sql);
     if ($this->db->query($sql)) {
         if (!empty($conf->global->CATEGORIE_RECURSIV_ADD)) {
             $sql = 'SELECT fk_parent FROM ' . MAIN_DB_PREFIX . 'categorie';
             $sql .= " WHERE rowid = " . $this->id;
             dol_syslog(get_class($this) . "::add_type sql=" . $sql);
             $resql = $this->db->query($sql);
             if ($resql) {
                 if ($this->db->num_rows($resql) > 0) {
                     $objparent = $this->db->fetch_object($resql);
                     if (!empty($objparent->fk_parent)) {
                         $cat = new Categorie($this->db);
                         $cat->id = $objparent->fk_parent;
                         $result = $cat->add_type($obj, $type);
                         if ($result < 0) {
                             $this->error = $cat->error;
                             $error++;
                         }
                     }
                 }
             } else {
                 $error++;
                 $this->error = $this->db->lasterror();
             }
             if ($error) {
                 return -1;
             }
         }
         // Save object we want to link category to into category instance to provide information to trigger
         $this->linkto = $obj;
         // Appel des triggers
         include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
         $interface = new Interfaces($this->db);
         $result = $interface->run_triggers('CATEGORY_LINK', $this, $user, $langs, $conf);
         if ($result < 0) {
             $error++;
             $this->errors = $interface->errors;
             $this->error = $interface->error;
         }
         // Fin appel triggers
         if (!$error) {
             return 1;
         } else {
             return -2;
         }
     } else {
         if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
             $this->error = $this->db->lasterrno();
             return -3;
         } else {
             $this->error = $this->db->lasterror();
         }
         return -1;
     }
 }
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:88,代码来源:categorie.class.php

示例8: testCategorieProduct

 /**
  * testCategorieProduct
  *
  * @param   int $id     Id of category
  * @return  int
  *
  * @depends testCategorieCreate
  * The depends says test is run only if previous is ok
  */
 public function testCategorieProduct($id)
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     $localobjecttmp = new Categorie($this->savdb);
     $localobjecttmp->initAsSpecimen();
     $localobjecttmp->label = 'Specimen Category for product';
     $localobjecttmp->type = 0;
     // product category
     $catid = $localobjecttmp->create($user);
     print __METHOD__ . " catid=" . $catid . "\n";
     $this->assertGreaterThan(0, $catid);
     // Try to create product linked to category
     $localobject2 = new Product($this->savdb);
     $localobject2->initAsSpecimen();
     $localobject2->ref .= '-CATEG';
     $localobject2->tva_npr = 1;
     $result = $localobject2->create($user);
     $cat = new Categorie($this->savdb);
     $cat->id = $catid;
     $result = $cat->add_type($localobject2, "product");
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertGreaterThan(0, $result);
     // Get list of categories for product
     $localcateg = new Categorie($this->savdb);
     $listofcateg = $localcateg->containing($localobject2->id, 'product', 'label');
     $this->assertTrue(in_array('Specimen Category for product', $listofcateg), 'Categ not found linked to product when it should');
     return $id;
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:41,代码来源:CategorieTest.php

示例9: Societe

	{
		$object = new Societe($db);
		$result = $object->fetch($objectid);
		$type = 'societe';
	}
	if ($_REQUEST["type"]==3 && $user->rights->adherent->creer)
	{
		require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
		$object = new Adherent($db);
		$result = $object->fetch($objectid);
		$type = 'member';
	}
	$cat = new Categorie($db);
	$result=$cat->fetch($_REQUEST["catMere"]);

	$result=$cat->add_type($object,$type);
	if ($result >= 0)
	{
		$mesg='<div class="ok">'.$langs->trans("WasAddedSuccessfully",$cat->label).'</div>';
	}
	else
	{
		if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') $mesg='<div class="warning">'.$langs->trans("ObjectAlreadyLinkedToCategory").'</div>';
		else $mesg='<div class="error">'.$langs->trans("Error").' '.$cat->error.'</div>';
	}

}


/*
 *	View
开发者ID:remyyounes,项目名称:dolibarr,代码行数:31,代码来源:categorie.php


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