diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 918244528cc..bda67f809fa 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -137,8 +137,10 @@ if (empty($reshook)) } // Reopen a closed order - else if ($action == 'reopen' && $user->rights->commande->creer) { - if ($object->statut == 3) { + else if ($action == 'reopen' && $user->rights->commande->creer) + { + if ($object->statut == 3) + { $result = $object->set_reopen($user); if ($result > 0) { @@ -153,21 +155,26 @@ if (empty($reshook)) } // Suppression de la commande - else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->commande->supprimer) { + else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->commande->supprimer) + { $result = $object->delete($user); - if ($result > 0) { + if ($result > 0) + { header('Location: index.php'); exit; } - else { + else + { setEventMessage($object->error, 'errors'); } } // Remove a product line - else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer) { + else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer) + { $result = $object->deleteline($lineid); - if ($result > 0) { + if ($result > 0) + { // Define output language $outputlangs = $langs; $newlang = ''; @@ -194,12 +201,14 @@ if (empty($reshook)) } // Categorisation dans projet - else if ($action == 'classin' && $user->rights->commande->creer) { + else if ($action == 'classin' && $user->rights->commande->creer) + { $object->setProject(GETPOST('projectid')); } // Add order - else if ($action == 'add' && $user->rights->commande->creer) { + else if ($action == 'add' && $user->rights->commande->creer) + { $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); @@ -239,7 +248,8 @@ if (empty($reshook)) $object->contactid = GETPOST('contactid'); // If creation from another object of another module (Example: origin=propal, originid=1) - if (! empty($origin) && ! empty($originid)) { + if (! empty($origin) && ! empty($originid)) + { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { @@ -301,37 +311,37 @@ if (empty($reshook)) for($i = 0; $i < $num; $i ++) { - $label = (! empty($lines [$i]->label) ? $lines [$i]->label : ''); - $desc = (! empty($lines [$i]->desc) ? $lines [$i]->desc : $lines [$i]->libelle); - $product_type = (! empty($lines [$i]->product_type) ? $lines [$i]->product_type : 0); + $label = (! empty($lines[$i]->label) ? $lines[$i]->label : ''); + $desc = (! empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle); + $product_type = (! empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); // Dates // TODO mutualiser - $date_start = $lines [$i]->date_debut_prevue; - if ($lines [$i]->date_debut_reel) - $date_start = $lines [$i]->date_debut_reel; - if ($lines [$i]->date_start) - $date_start = $lines [$i]->date_start; - $date_end = $lines [$i]->date_fin_prevue; - if ($lines [$i]->date_fin_reel) - $date_end = $lines [$i]->date_fin_reel; - if ($lines [$i]->date_end) - $date_end = $lines [$i]->date_end; + $date_start = $lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) + $date_start = $lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) + $date_start = $lines[$i]->date_start; + $date_end = $lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) + $date_end = $lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) + $date_end = $lines[$i]->date_end; // Reset fk_parent_line for no child products and special product - if (($lines [$i]->product_type != 9 && empty($lines [$i]->fk_parent_line)) || $lines [$i]->product_type == 9) { + if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { $fk_parent_line = 0; } // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines [$i], 'fetch_optionals')) // For avoid conflicts if + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if // trigger used { - $lines [$i]->fetch_optionals($lines [$i]->rowid); - $array_option = $lines [$i]->array_options; + $lines[$i]->fetch_optionals($lines[$i]->rowid); + $array_option = $lines[$i]->array_options; } - $result = $object->addline($desc, $lines [$i]->subprice, $lines [$i]->qty, $lines [$i]->tva_tx, $lines [$i]->localtax1_tx, $lines [$i]->localtax2_tx, $lines [$i]->fk_product, $lines [$i]->remise_percent, $lines [$i]->info_bits, $lines [$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines [$i]->rang, $lines [$i]->special_code, $fk_parent_line, $lines [$i]->fk_fournprice, $lines [$i]->pa_ht, $label, $array_option); + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_option); if ($result < 0) { $error ++; @@ -339,7 +349,7 @@ if (empty($reshook)) } // Defined the new fk_parent_line - if ($result > 0 && $lines [$i]->product_type == 9) { + if ($result > 0 && $lines[$i]->product_type == 9) { $fk_parent_line = $result; } } @@ -385,8 +395,10 @@ if (empty($reshook)) } // Insert default contacts if defined - if ($object_id > 0) { - if (GETPOST('contactid')) { + if ($object_id > 0) + { + if (GETPOST('contactid')) + { $result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external'); if ($result < 0) { setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); @@ -399,7 +411,8 @@ if (empty($reshook)) } // End of object creation, we show it - if ($object_id > 0 && ! $error) { + if ($object_id > 0 && ! $error) + { $db->commit(); header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object_id); exit(); @@ -1594,7 +1607,8 @@ if ($action == 'create' && $user->rights->commande->creer) /* * Confirmation de la validation */ - if ($action == 'validate') { + if ($action == 'validate') + { // on verifie si l'objet est en numerotation provisoire $ref = substr($object->ref, 1, 4); if ($ref == 'PROV') { @@ -1604,7 +1618,8 @@ if ($action == 'create' && $user->rights->commande->creer) } $text = $langs->trans('ConfirmValidateOrder', $numref); - if (! empty($conf->notification->enabled)) { + if (! empty($conf->notification->enabled)) + { require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; $notify = new Notify($db); $text .= '
'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index aed2aa3b224..b886a382b1e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -175,8 +175,8 @@ abstract class CommonObject /** * Add a link between element $this->element and a contact * - * @param int $fk_socpeople Id of contact to link - * @param int $type_contact Type of contact (code or id). For example: SALESREPFOLL + * @param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if souce = 'internal') to link + * @param int $type_contact Type of contact (code or id). Must be if or code found into table llx_c_type_contact. For example: SALESREPFOLL * @param int $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 64131be840b..2914ca95620 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -613,7 +613,7 @@ class CommandeFournisseur extends CommonOrder } /** - * Accept an order + * Approve a supplier order * * @param User $user Object user * @param int $idwarehouse Id of warhouse for stock change @@ -659,6 +659,15 @@ class CommandeFournisseur extends CommonOrder { $this->log($user, 2, time()); // Statut 2 + if (! empty($conf->global->SUPPLIER_ORDER_AUTOADD_USER_CONTACT)) + { + $result=$this->add_contact($user->id, 'SALESREPFOLL', 'internal', 1); + if ($result < 0) + { + $error++; + } + } + // If stock is incremented on validate order, we must increment it if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { @@ -967,8 +976,8 @@ class CommandeFournisseur extends CommonOrder dol_syslog(get_class($this)."::create", LOG_DEBUG); if ($this->db->query($sql)) { - // On logue creation pour historique - $this->log($user, 0, time()); + // Add entry into log + $this->log($user, 0, $now); if (! $error) { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index ed276d7b328..f449c7f1098 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2014 Juanjo Menent @@ -1601,13 +1601,13 @@ elseif (! empty($object->id)) } print ''; - + // Delai livraison jours print ''; print ''.$langs->trans('NbDaysToDelivery').' '.img_picto($langs->trans('DescNbDaysToDelivery'), 'info', 'style="cursor:help"').''; print ''.$object->getMaxDeliveryTimeDay($langs).''; print ''; - + // Project if (! empty($conf->projet->enabled)) { @@ -2232,8 +2232,12 @@ elseif (! empty($object->id)) if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->commande->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_order_advance->validate))) { - print ''.$langs->trans('Validate').''; + $tmpbuttonlabel=$langs->trans('Validate'); + if ($user->rights->fournisseur->commande->approuver) $tmpbuttonlabel = $langs->trans("ValidateAndApprove"); + + print ''; + print $tmpbuttonlabel; + print ''; } }