本文整理汇总了PHP中CommandeFournisseur::create方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandeFournisseur::create方法的具体用法?PHP CommandeFournisseur::create怎么用?PHP CommandeFournisseur::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandeFournisseur
的用法示例。
在下文中一共展示了CommandeFournisseur::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CommandeFournisseur
/**
* \brief Cree la commande au statut brouillon
* \param user Utilisateur qui cree
* \return int <0 si ko, id de la commande creee si ok
*/
function create_commande($user)
{
dol_syslog("Fournisseur::Create_Commande");
$comm = new CommandeFournisseur($this->db);
$comm->socid = $this->id;
if ($comm->create($user) > 0)
{
$this->single_open_commande = $comm->id;
return $comm->id;
}
else
{
$this->error=$comm->error;
dol_syslog("Fournisseur::Create_Commande Failed ".$this->error, LOG_ERR);
return -1;
}
}
示例2: setEventMessages
$msg .= $order->error;
setEventMessages($msg, null, 'errors');
} else {
$id = $result;
}
} else {
$order->socid = $suppliersid[$i];
$order->fetch_thirdparty();
//trick to know which orders have been generated this way
$order->source = 42;
foreach ($supplier['lines'] as $line) {
$order->lines[] = $line;
}
$order->cond_reglement_id = $order->thirdparty->cond_reglement_supplier_id;
$order->mode_reglement_id = $order->thirdparty->mode_reglement_supplier_id;
$id = $order->create($user);
if ($id < 0) {
$fail++;
$msg = $langs->trans('OrderFail') . " : ";
$msg .= $order->error;
setEventMessages($msg, null, 'errors');
}
$i++;
}
}
if (!$fail && $id) {
$db->commit();
setEventMessages($langs->trans('OrderCreated'), null, 'mesgs');
header('Location: replenishorders.php');
exit;
} else {
示例3: testCommandeFournisseurCreate
/**
* testCommandeFournisseurCreate
*
* @return void
*/
public function testCommandeFournisseurCreate()
{
global $conf, $user, $langs, $db;
$conf = $this->savconf;
$user = $this->savuser;
$langs = $this->savlangs;
$db = $this->savdb;
// Set supplier and product to use
$socid = 1;
$societe = new Societe($db);
$societe->fetch($socid);
$product = new ProductFournisseur($db);
$product->fetch(0, 'PIDRESS');
if ($product->id <= 0) {
print "\n" . __METHOD__ . " A product with ref PIDRESS must exists into database";
die;
}
$quantity = 10;
$ref_fourn = 'SUPPLIER_REF_PHPUNIT';
$tva_tx = 19.6;
// Create supplier price
$result = $product->add_fournisseur($user, $societe->id, $ref_fourn, $quantity);
// This insert record with no value for price. Values are update later with update_buyprice
$this->assertGreaterThanOrEqual(1, $result);
$result = $product->update_buyprice($quantity, 10, $user, 'HT', $societe, '', $ref_fourn, $tva_tx, 0, 0);
$this->assertGreaterThanOrEqual(0, $result);
// Create supplier order with a too low quantity
$localobject = new CommandeFournisseur($db);
$localobject->initAsSpecimen();
$localobject->lines = array();
// Overwrite lines of order
$line = new CommandeFournisseurLigne($db);
$line->desc = $langs->trans("Description") . " specimen line too low";
$line->qty = 1;
// So lower than $quantity
$line->fk_product = $product->id;
$line->ref_fourn = $ref_fourn;
$localobject->lines[] = $line;
$result = $localobject->create($user);
print __METHOD__ . " result=" . $result . "\n";
$this->assertEquals(-1, $result);
// must be -1 because quantity is lower than minimum of supplier price
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "commande_fournisseur where ref=''";
$db->query($sql);
// Create supplier order
$localobject2 = new CommandeFournisseur($db);
$localobject2->initAsSpecimen();
// This create 5 lines of first product found for socid 1
$localobject2->lines = array();
// Overwrite lines of order
$line = new CommandeFournisseurLigne($db);
$line->desc = $langs->trans("Description") . " specimen line ok";
$line->qty = 10;
// So enough quantity
$line->fk_product = $product->id;
$line->ref_fourn = $ref_fourn;
$localobject2->lines[] = $line;
$result = $localobject2->create($user);
print __METHOD__ . " result=" . $result . "\n";
$this->assertGreaterThanOrEqual(0, $result);
return $result;
}
示例4: testCommandeFournisseurCreate
/**
*/
public function testCommandeFournisseurCreate()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new CommandeFournisseur($this->savdb);
$localobject->initAsSpecimen();
$result=$localobject->create($user);
print __METHOD__." result=".$result."\n";
$this->assertLessThan($result, 0);
return $result;
}
示例5: addCommandeFourn
private function addCommandeFourn(&$PDOdb, $ofLigne, $resultatSQL)
{
global $db, $user;
dol_include_once("fourn/class/fournisseur.commande.class.php");
// On cherche s'il existe une commande pour ce fournisseur
$sql = "SELECT rowid";
$sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseur";
$sql .= " WHERE fk_soc = " . $resultatSQL->fk_soc;
$sql .= " AND fk_statut = 0";
//uniquement brouillon
$sql .= " ORDER BY rowid DESC";
$sql .= " LIMIT 1";
$resql = $db->query($sql);
$res = $db->fetch_object($resql);
if ($res) {
// Il existe une commande, on la charge
$com = new CommandeFournisseur($db);
$com->fetch($res->rowid);
} else {
// Il n'existe aucune commande pour ce fournisseur donc on en crée une nouvelle
$com = new CommandeFournisseur($db);
$com->socid = $resultatSQL->fk_soc;
$com->create($user);
}
// On cherche si ce produit existe déjà dans la commande, si oui, : "updateline"
foreach ($com->lines as $line) {
if ($line->fk_product == $resultatSQL->fk_product) {
$com->updateline($line->id, $line->desc, $line->subprice, $line->qty + $ofLigne->qty, $line->remise_percent, $line->tva_tx);
$done = true;
break;
}
}
if (!$done) {
// Si le produit n'existe pas déjà dans la commande, on l'ajoute à cette commande
$com->addline($desc, $resultatSQL->price / $resultatSQL->quantity, $ofLigne->qty, $txtva, 0, 0, $resultatSQL->fk_product, $resultatSQL->rowid);
}
//Création association element_element entre la commande fournisseur et l'OF
$this->addElementElement($PDOdb, $com, $ofLigne);
}