本文整理汇总了PHP中Commande::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Commande::create方法的具体用法?PHP Commande::create怎么用?PHP Commande::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Commande
的用法示例。
在下文中一共展示了Commande::create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: confirmedCart
public function confirmedCart()
{
//on récupère l'id du client
$id = Session::get('client_id');
//on trouve le client avec son id
$user = User::find($id);
//on charge les données pour la création de la commande
$data = array('id_client' => $user->id);
//on créer une nouvelle commande
$commande = Commande::create($data);
//on récupère les données de la session cart
$cart_aray = Session::get('cart');
foreach ($cart_aray as $c_array) {
foreach ($c_array as $cart_line) {
//on charge les données avant de créer une nouvelle ligne de commande
$data = array('id_client' => $user->id, 'id_produit' => $cart_line['id'], 'quantite' => 1, 'id_command' => $commande->id);
// pour chaque tour, on crée une nouvelle ligne de commande dans la base
$ligne_commande = LigneCommande::create($data);
}
}
//on supprime la session cart, et on la recrée vide.
Session::forget('cart');
Session::put('cart.items', '');
return View::make('confirmed_cart');
}
示例2: post
/**
* Create order object
*
* @param array $request_data Request datas
*
* @url POST order/
*
* @return int ID of commande
*/
function post($request_data = NULL)
{
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
// Check mandatory fields
$result = $this->_validate($request_data);
foreach ($request_data as $field => $value) {
$this->commande->{$field} = $value;
}
if (!$this->commande->create(DolibarrApiAccess::$user)) {
throw new RestException(401);
}
return $this->commande->ref;
}
示例3: createFromClone
/**
* Load an object from its id and create a new one in database
* @param fromid Id of object to clone
* @param invertdetail Reverse sign of amounts for lines
* @param socid Id of thirdparty
* @return int New id of clone
*/
function createFromClone($fromid, $invertdetail = 0, $socid = 0)
{
global $conf, $user, $langs;
$error = 0;
$object = new Commande($this->db);
// Instantiate hooks of thirdparty module
if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules)) {
$object->callHooks('ordercard');
}
$this->db->begin();
// Load source object
$object->fetch($fromid);
$objFrom = $object;
// Change socid if needed
if (!empty($socid) && $socid != $object->socid) {
$objsoc = new Societe($this->db);
if ($objsoc->fetch($socid) > 0) {
$object->socid = $objsoc->id;
$object->cond_reglement_id = !empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0;
$object->mode_reglement_id = !empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0;
$object->fk_project = '';
$object->fk_delivery_address = '';
}
// TODO Change product price if multi-prices
}
$object->id = 0;
$object->statut = 0;
// Clear fields
$object->user_author_id = $user->id;
$object->user_valid = '';
$object->date_creation = '';
$object->date_validation = '';
$object->ref_client = '';
// Create clone
$result = $object->create($user);
// Other options
if ($result < 0) {
$this->error = $object->error;
$error++;
}
if (!$error) {
// Hook of thirdparty module
if (!empty($object->hooks)) {
foreach ($object->hooks as $hook) {
if (!empty($hook['modules'])) {
foreach ($hook['modules'] as $module) {
if (method_exists($module, 'createfrom')) {
$result = $module->createfrom($objFrom, $result, $object->element);
if ($result < 0) {
$error++;
}
}
}
}
}
}
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
$interface = new Interfaces($this->db);
$result = $interface->run_triggers('ORDER_CLONE', $object, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// Fin appel triggers
}
// End
if (!$error) {
$this->db->commit();
return $object->id;
} else {
$this->db->rollback();
return -1;
}
}
示例4: testCommandeCreate
/**
* testCommandeCreate
*
* @return void
*/
public function testCommandeCreate()
{
global $conf, $user, $langs, $db;
$conf = $this->savconf;
$user = $this->savuser;
$langs = $this->savlangs;
$db = $this->savdb;
$localobject = new Commande($this->savdb);
$localobject->initAsSpecimen();
$result = $localobject->create($user);
$this->assertLessThan($result, 0);
print __METHOD__ . " result=" . $result . "\n";
return $result;
}
示例5: Commande
// Create order object
$com = new Commande($db);
$com->ref = 'ABCDE';
$com->socid = 4;
// Put id of third party (rowid in llx_societe table)
$com->date_commande = mktime();
$com->note = 'A comment';
$com->source = 1;
$com->remise_percent = 0;
$orderline1 = new OrderLine($db);
$orderline1->tva_tx = 10.0;
$orderline1->remise_percent = 0;
$orderline1->qty = 1;
$com->lines[] = $orderline1;
// Create order
$idobject = $com->create($user);
if ($idobject > 0) {
// Change status to validated
$result = $com->valid($user);
if ($result > 0) {
print "OK Object created with id " . $idobject . "\n";
} else {
$error++;
dol_print_error($db, $com->error);
}
} else {
$error++;
dol_print_error($db, $com->error);
}
// -------------------- END OF YOUR CODE --------------------
if (!$error) {
示例6: array
}
}
$dates = array(mktime(12, 0, 0, 1, 3, 2003), mktime(12, 0, 0, 1, 9, 2003), mktime(12, 0, 0, 2, 13, 2003), mktime(12, 0, 0, 2, 23, 2003), mktime(12, 0, 0, 3, 30, 2003), mktime(12, 0, 0, 4, 3, 2003), mktime(12, 0, 0, 4, 3, 2003), mktime(12, 0, 0, 5, 9, 2003), mktime(12, 0, 0, 5, 1, 2003), mktime(12, 0, 0, 5, 13, 2003), mktime(12, 0, 0, 5, 19, 2003), mktime(12, 0, 0, 5, 23, 2003), mktime(12, 0, 0, 6, 3, 2003), mktime(12, 0, 0, 6, 19, 2003), mktime(12, 0, 0, 6, 24, 2003), mktime(12, 0, 0, 7, 3, 2003), mktime(12, 0, 0, 7, 9, 2003), mktime(12, 0, 0, 7, 23, 2003), mktime(12, 0, 0, 7, 30, 2003), mktime(12, 0, 0, 8, 9, 2003), mktime(12, 0, 0, 9, 23, 2003), mktime(12, 0, 0, 10, 3, 2003), mktime(12, 0, 0, 11, 12, 2003), mktime(12, 0, 0, 11, 13, 2003), mktime(12, 0, 0, 1, 3, 2002), mktime(12, 0, 0, 1, 9, 2002), mktime(12, 0, 0, 2, 13, 2002), mktime(12, 0, 0, 2, 23, 2002), mktime(12, 0, 0, 3, 30, 2002), mktime(12, 0, 0, 4, 3, 2002), mktime(12, 0, 0, 4, 3, 2002), mktime(12, 0, 0, 5, 9, 2002), mktime(12, 0, 0, 5, 1, 2002), mktime(12, 0, 0, 5, 13, 2002), mktime(12, 0, 0, 5, 19, 2002), mktime(12, 0, 0, 5, 23, 2002), mktime(12, 0, 0, 6, 3, 2002), mktime(12, 0, 0, 6, 19, 2002), mktime(12, 0, 0, 6, 24, 2002), mktime(12, 0, 0, 7, 3, 2002), mktime(12, 0, 0, 7, 9, 2002), mktime(12, 0, 0, 7, 23, 2002), mktime(12, 0, 0, 7, 30, 2002), mktime(12, 0, 0, 8, 9, 2002), mktime(12, 0, 0, 9, 23, 2002), mktime(12, 0, 0, 10, 3, 2002), mktime(12, 0, 0, 11, 12, 2003), mktime(12, 0, 0, 11, 13, 2003), mktime(12, 0, 0, 12, 12, 2003), mktime(12, 0, 0, 12, 13, 2003));
require DOL_DOCUMENT_ROOT . "/commande/class/commande.class.php";
print "Build " . GEN_NUMBER_COMMANDE . " orders\n";
for ($s = 0; $s < GEN_NUMBER_COMMANDE; $s++) {
print "Process order " . $s . "\n";
$com = new Commande($db);
$com->socid = 4;
$com->date_commande = $dates[rand(1, count($dates) - 1)];
$com->note = 'A comment';
$com->source = 1;
$com->fk_project = 0;
$com->remise_percent = 0;
$db->begin();
$result = $com->create($user);
if ($result >= 0) {
$result = $com->valid($user);
if ($result > 0) {
$nbp = rand(2, 5);
$xnbp = 0;
while ($xnbp < $nbp) {
$prodid = rand(1, $num_prods);
$product = new Product($db);
$result = $product->fetch($prodids[$prodid]);
$result = $com->addline($product->description, $product->price, rand(1, 5), 0, 0, 0, $prodids[$prodid], 0, 0, 0, $product->price_base_type, $product->price_ttc, '', '', $product->type);
if ($result < 0) {
dol_print_error($db, $propal->error);
}
$xnbp++;
}
示例7: createOrder
/**
* Create order
*
* @param array $authentication Array of authentication information
* @param array $order Order info
* @return int Id of new order
*/
function createOrder($authentication, $order)
{
global $db, $conf, $langs;
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
$now = dol_now();
dol_syslog("Function: createOrder login=" . $authentication['login'] . " socid :" . $order['socid']);
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 (!$error) {
$newobject = new Commande($db);
$newobject->socid = $order['thirdparty_id'];
$newobject->type = $order['type'];
$newobject->ref_ext = $order['ref_ext'];
$newobject->date = dol_stringtotime($order['date'], 'dayrfc');
$newobject->date_lim_reglement = dol_stringtotime($order['date_due'], 'dayrfc');
$newobject->note_private = $order['note_private'];
$newobject->note_public = $order['note_public'];
$newobject->statut = 0;
// We start with status draft
$newobject->billed = $order['billed'];
$newobject->fk_project = $order['project_id'];
$newobject->fk_delivery_address = $order['fk_delivery_address'];
$newobject->cond_reglement_id = $order['cond_reglement_id'];
$newobject->demand_reason_id = $order['demand_reason_id'];
$newobject->date_creation = $now;
// Retrieve all extrafield for order
// fetch optionals attributes and labels
$extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label('commandet', true);
foreach ($extrafields->attribute_label as $key => $label) {
$key = 'options_' . $key;
$newobject->array_options[$key] = $order[$key];
}
// Trick because nusoap does not store data with same structure if there is one or several lines
$arrayoflines = array();
if (isset($order['lines']['line'][0])) {
$arrayoflines = $order['lines']['line'];
} else {
$arrayoflines = $order['lines'];
}
foreach ($arrayoflines as $key => $line) {
// $key can be 'line' or '0','1',...
$newline = new OrderLine($db);
$newline->type = $line['type'];
$newline->desc = $line['desc'];
$newline->fk_product = $line['product_id'];
$newline->tva_tx = $line['vat_rate'];
$newline->qty = $line['qty'];
$newline->price = $line['price'];
$newline->subprice = $line['unitprice'];
$newline->total_ht = $line['total_net'];
$newline->total_tva = $line['total_vat'];
$newline->total_ttc = $line['total'];
$newline->date_start = $line['date_start'];
$newline->date_end = $line['date_end'];
// Retrieve all extrafield for lines
// fetch optionals attributes and labels
$extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label('commandedet', true);
foreach ($extrafields->attribute_label as $key => $label) {
$key = 'options_' . $key;
$newline->array_options[$key] = $line[$key];
}
$newobject->lines[] = $newline;
}
$db->begin();
dol_syslog("Webservice server_order:: order creation start", LOG_DEBUG);
$result = $newobject->create($fuser);
dol_syslog('Webservice server_order:: order creation done with $result=' . $result, LOG_DEBUG);
if ($result < 0) {
dol_syslog("Webservice server_order:: order creation failed", LOG_ERR);
$error++;
}
if ($order['status'] == 1) {
dol_syslog("Webservice server_order:: order validation start", LOG_DEBUG);
$result = $newobject->valid($fuser);
if ($result < 0) {
dol_syslog("Webservice server_order:: order validation failed", LOG_ERR);
$error++;
}
}
if ($result >= 0) {
dol_syslog("Webservice server_order:: order creation & validation succeeded, commit", LOG_DEBUG);
$db->commit();
$objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $newobject->id, 'ref' => $newobject->ref);
//.........这里部分代码省略.........