diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php
index 1bdbacf434e..13820292dc3 100644
--- a/htdocs/supplier_proposal/card.php
+++ b/htdocs/supplier_proposal/card.php
@@ -1254,236 +1254,242 @@ if ($action == 'create') {
print dol_get_fiche_head();
- print '
';
-
- // Reference
- print '| '.$langs->trans('Ref').' | '.$langs->trans("Draft").' |
';
-
- // Third party
- print '';
- print '| '.$langs->trans('Supplier').' | ';
- if ($socid > 0) {
- print '';
- print $soc->getNomUrl(1, 'supplier');
- print '';
- print ' | ';
- } else {
- print '';
- $filter = '((s.fournisseur:=:1) AND (s.status:=:1))';
- print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company((empty($socid) ? '' : $socid), 'socid', $filter, 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx');
- // reload page to retrieve customer informations
- if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) {
- print '';
- }
- print ' ';
- print ' | ';
- }
- print '
'."\n";
-
- if ($soc->id > 0) {
- // Discounts for third party
- print '| '.$langs->trans('Discounts').' | ';
-
- $absolute_discount = $soc->getAvailableDiscounts('', '', 0, 1);
-
- $thirdparty = $soc;
- $discount_type = 1;
- $backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid'));
- include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
-
- print ' |
';
- }
-
- // Terms of payment
- print '| '.$langs->trans('PaymentConditionsShort').' | ';
- print img_picto('', 'payment', 'class="pictofixedwidth"');
- print $form->getSelectConditionsPaiements(GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $cond_reglement_id, 'cond_reglement_id', -1, 1);
- print ' |
';
-
- // Mode of payment
- print '| '.$langs->trans('PaymentMode').' | ';
- print img_picto('', 'bank', 'class="pictofixedwidth"');
- $form->select_types_paiements(GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $mode_reglement_id, 'mode_reglement_id');
- print ' |
';
-
- // Bank Account
- if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && isModEnabled("banque")) {
- print '| '.$langs->trans('BankAccount').' | ';
- $form->select_comptes(GETPOST('fk_account') > 0 ? GETPOST('fk_account', 'int') : $fk_account, 'fk_account', 0, '', 1);
- print ' |
';
- }
-
- // Shipping Method
- if (isModEnabled("expedition")) {
- print '| '.$langs->trans('SendingMethod').' | ';
- print img_picto('', 'dolly', 'class="pictofixedwidth"');
- $form->selectShippingMethod(GETPOST('shipping_method_id') > 0 ? GETPOST('shipping_method_id', 'int') : "", 'shipping_method_id', '', 1);
- print ' |
';
- }
-
- // Delivery date (or manufacturing)
- print '| '.$langs->trans("DeliveryDate").' | ';
- print '';
- print img_picto('', 'action', 'class="pictofixedwidth"');
- $datedelivery = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year'));
- if (is_numeric(getDolGlobalString('DATE_LIVRAISON_WEEK_DELAY'))) { // If value set to 0 or a num, not empty
- $tmpdte = time() + (7 * getDolGlobalInt('DATE_LIVRAISON_WEEK_DELAY') * 24 * 60 * 60);
- $syear = date("Y", $tmpdte);
- $smonth = date("m", $tmpdte);
- $sday = date("d", $tmpdte);
- print $form->selectDate($syear."-".$smonth."-".$sday, 'liv_', '', '', '', "addask");
- } else {
- print $form->selectDate($datedelivery ? $datedelivery : -1, 'liv_', '', '', '', "addask", 1, 1);
- }
- print ' |
';
-
-
- // Model
- print '';
- print '| '.$langs->trans("DefaultModel").' | ';
- print '';
- print img_picto('', 'pdf', 'class="pictofixedwidth"');
- $list = ModelePDFSupplierProposal::liste_modeles($db);
- $preselected = (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT) ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT : $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF);
- print $form->selectarray('model', $list, $preselected, 0, 0, 0, '', 0, 0, 0, '', '', 1);
- print " |
";
-
- // Project
- if (isModEnabled('project')) {
- $langs->load("projects");
-
- $formproject = new FormProjets($db);
-
- if ($origin == 'project') {
- $projectid = ($originid ? $originid : 0);
- }
-
- print '';
- print '| '.$langs->trans("Project").' | ';
- print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
- print ' id).'">';
-
- print ' | ';
- print '
';
- }
-
- // Multicurrency
- if (isModEnabled("multicurrency")) {
- print '';
- print '| '.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).' | ';
- print '';
- print img_picto('', 'currency', 'class="pictofixedwidth"');
- print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
- print ' |
';
- }
-
- // Other attributes
- $parameters = array('colspan' => ' colspan="3"', 'cols' => 3);
- $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
+ // Call Hook tabContentCreateSupplierProposal
+ $parameters = array();
+ // Note that $action and $object may be modified by hook
+ $reshook = $hookmanager->executeHooks('tabContentCreateSupplierProposal', $parameters, $object, $action);
if (empty($reshook)) {
- print $object->showOptionals($extrafields, 'create', $parameters);
- }
+ print '';
+ // Reference
+ print '| '.$langs->trans('Ref').' | '.$langs->trans("Draft").' |
';
- // Lines from source
- if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
- // TODO for compatibility
- if ($origin == 'contrat') {
- // Calcul contrat->price (HT), contrat->total (TTC), contrat->tva
- //$objectsrc->remise_absolue = $remise_absolue;
- //$objectsrc->remise_percent = $remise_percent;
- $objectsrc->update_price(1, 'auto', 1);
- }
-
- print "\n";
- print "\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
- print '';
- print '';
-
- print '| '.$langs->trans('CommRequest').' | '.$objectsrc->getNomUrl(1).' |
';
- print '| '.$langs->trans('AmountHT').' | '.price($objectsrc->total_ht).' |
';
- print '| '.$langs->trans('AmountVAT').' | '.price($objectsrc->total_tva)." |
";
- if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) { // Localtax1
- print '| '.$langs->transcountry("AmountLT1", $mysoc->country_code).' | '.price($objectsrc->total_localtax1)." |
";
- }
-
- if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) { // Localtax2
- print '| '.$langs->transcountry("AmountLT2", $mysoc->country_code).' | '.price($objectsrc->total_localtax2)." |
";
- }
- print '| '.$langs->trans('AmountTTC').' | '.price($objectsrc->total_ttc)." |
";
-
- if (isModEnabled("multicurrency")) {
- print '| '.$langs->trans('MulticurrencyAmountHT').' | '.price($objectsrc->multicurrency_total_ht).' |
';
- print '| '.$langs->trans('MulticurrencyAmountVAT').' | '.price($objectsrc->multicurrency_total_tva)." |
";
- print '| '.$langs->trans('MulticurrencyAmountTTC').' | '.price($objectsrc->multicurrency_total_ttc)." |
";
- }
- }
-
- print "
\n";
-
-
- /*
- * Combobox for copy function
- */
-
- if (empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) {
- print '';
- }
-
- if (!empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) {
- print '
';
-
- // For backward compatibility
+ // Third party
print '';
- print ' | ';
- print ''.$langs->trans("CopyAskFrom").' | ';
- print '';
- $liste_ask = array();
- $liste_ask [0] = '';
-
- $sql = "SELECT p.rowid as id, p.ref, s.nom";
- $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal p";
- $sql .= ", ".MAIN_DB_PREFIX."societe s";
- $sql .= " WHERE s.rowid = p.fk_soc";
- $sql .= " AND p.entityy IN (".getEntity('supplier_proposal').")";
- $sql .= " AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT;
- $sql .= " ORDER BY Id";
-
- $resql = $db->query($sql);
- if ($resql) {
- $num = $db->num_rows($resql);
- $i = 0;
- while ($i < $num) {
- $row = $db->fetch_row($resql);
- $askPriceSupplierRefAndSocName = $row[1]." - ".$row[2];
- $liste_ask[$row[0]] = $askPriceSupplierRefAndSocName;
- $i++;
- }
- print $form->selectarray("copie_supplier_proposal", $liste_ask, 0);
+ print ' | '.$langs->trans('Supplier').' | ';
+ if ($socid > 0) {
+ print '';
+ print $soc->getNomUrl(1, 'supplier');
+ print '';
+ print ' | ';
} else {
- dol_print_error($db);
+ print '';
+ $filter = '((s.fournisseur:=:1) AND (s.status:=:1))';
+ print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company((empty($socid) ? '' : $socid), 'socid', $filter, 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx');
+ // reload page to retrieve customer informations
+ if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) {
+ print '';
+ }
+ print ' ';
+ print ' | ';
+ }
+ print '
'."\n";
+
+ if ($soc->id > 0) {
+ // Discounts for third party
+ print '| '.$langs->trans('Discounts').' | ';
+
+ $absolute_discount = $soc->getAvailableDiscounts('', '', 0, 1);
+
+ $thirdparty = $soc;
+ $discount_type = 1;
+ $backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid'));
+ include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
+
+ print ' |
';
+ }
+
+ // Terms of payment
+ print '| '.$langs->trans('PaymentConditionsShort').' | ';
+ print img_picto('', 'payment', 'class="pictofixedwidth"');
+ print $form->getSelectConditionsPaiements(GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $cond_reglement_id, 'cond_reglement_id', -1, 1);
+ print ' |
';
+
+ // Mode of payment
+ print '| '.$langs->trans('PaymentMode').' | ';
+ print img_picto('', 'bank', 'class="pictofixedwidth"');
+ $form->select_types_paiements(GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $mode_reglement_id, 'mode_reglement_id');
+ print ' |
';
+
+ // Bank Account
+ if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && isModEnabled("banque")) {
+ print '| '.$langs->trans('BankAccount').' | ';
+ $form->select_comptes(GETPOST('fk_account') > 0 ? GETPOST('fk_account', 'int') : $fk_account, 'fk_account', 0, '', 1);
+ print ' |
';
+ }
+
+ // Shipping Method
+ if (isModEnabled("expedition")) {
+ print '| '.$langs->trans('SendingMethod').' | ';
+ print img_picto('', 'dolly', 'class="pictofixedwidth"');
+ $form->selectShippingMethod(GETPOST('shipping_method_id') > 0 ? GETPOST('shipping_method_id', 'int') : "", 'shipping_method_id', '', 1);
+ print ' |
';
+ }
+
+ // Delivery date (or manufacturing)
+ print '| '.$langs->trans("DeliveryDate").' | ';
+ print '';
+ print img_picto('', 'action', 'class="pictofixedwidth"');
+ $datedelivery = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year'));
+ if (is_numeric(getDolGlobalString('DATE_LIVRAISON_WEEK_DELAY'))) { // If value set to 0 or a num, not empty
+ $tmpdte = time() + (7 * getDolGlobalInt('DATE_LIVRAISON_WEEK_DELAY') * 24 * 60 * 60);
+ $syear = date("Y", $tmpdte);
+ $smonth = date("m", $tmpdte);
+ $sday = date("d", $tmpdte);
+ print $form->selectDate($syear."-".$smonth."-".$sday, 'liv_', '', '', '', "addask");
+ } else {
+ print $form->selectDate($datedelivery ? $datedelivery : -1, 'liv_', '', '', '', "addask", 1, 1);
}
print ' |
';
- print ' | ';
- print ''.$langs->trans("CreateEmptyAsk").' |
';
- }
- if (!empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) {
- print '
';
+ // Model
+ print '';
+ print '| '.$langs->trans("DefaultModel").' | ';
+ print '';
+ print img_picto('', 'pdf', 'class="pictofixedwidth"');
+ $list = ModelePDFSupplierProposal::liste_modeles($db);
+ $preselected = (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT) ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT : $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF);
+ print $form->selectarray('model', $list, $preselected, 0, 0, 0, '', 0, 0, 0, '', '', 1);
+ print " |
";
+
+ // Project
+ if (isModEnabled('project')) {
+ $langs->load("projects");
+
+ $formproject = new FormProjets($db);
+
+ if ($origin == 'project') {
+ $projectid = ($originid ? $originid : 0);
+ }
+
+ print '';
+ print '| '.$langs->trans("Project").' | ';
+ print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
+ print ' id).'">';
+
+ print ' | ';
+ print '
';
+ }
+
+ // Multicurrency
+ if (isModEnabled("multicurrency")) {
+ print '';
+ print '| '.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).' | ';
+ print '';
+ print img_picto('', 'currency', 'class="pictofixedwidth"');
+ print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
+ print ' |
';
+ }
+
+ // Other attributes
+ $parameters = array('colspan' => ' colspan="3"', 'cols' => 3);
+ $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ if (empty($reshook)) {
+ print $object->showOptionals($extrafields, 'create', $parameters);
+ }
+
+
+ // Lines from source
+ if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
+ // TODO for compatibility
+ if ($origin == 'contrat') {
+ // Calcul contrat->price (HT), contrat->total (TTC), contrat->tva
+ //$objectsrc->remise_absolue = $remise_absolue;
+ //$objectsrc->remise_percent = $remise_percent;
+ $objectsrc->update_price(1, 'auto', 1);
+ }
+
+ print "\n";
+ print "\n";
+ print ''."\n";
+ print ''."\n";
+ print ''."\n";
+ print '';
+ print '';
+
+ print '| '.$langs->trans('CommRequest').' | '.$objectsrc->getNomUrl(1).' |
';
+ print '| '.$langs->trans('AmountHT').' | '.price($objectsrc->total_ht).' |
';
+ print '| '.$langs->trans('AmountVAT').' | '.price($objectsrc->total_tva)." |
";
+ if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) { // Localtax1
+ print '| '.$langs->transcountry("AmountLT1", $mysoc->country_code).' | '.price($objectsrc->total_localtax1)." |
";
+ }
+
+ if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) { // Localtax2
+ print '| '.$langs->transcountry("AmountLT2", $mysoc->country_code).' | '.price($objectsrc->total_localtax2)." |
";
+ }
+ print '| '.$langs->trans('AmountTTC').' | '.price($objectsrc->total_ttc)." |
";
+
+ if (isModEnabled("multicurrency")) {
+ print '| '.$langs->trans('MulticurrencyAmountHT').' | '.price($objectsrc->multicurrency_total_ht).' |
';
+ print '| '.$langs->trans('MulticurrencyAmountVAT').' | '.price($objectsrc->multicurrency_total_tva)." |
";
+ print '| '.$langs->trans('MulticurrencyAmountTTC').' | '.price($objectsrc->multicurrency_total_ttc)." |
";
+ }
+ }
+
+ print "
\n";
+
+
+ /*
+ * Combobox for copy function
+ */
+
+ if (empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) {
+ print '