New: Merge free product and predefined product area to enter new
product.
This commit is contained in:
parent
cc8dcacbc9
commit
d224128c46
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
@ -539,34 +539,24 @@ else if ($action == "setabsolutediscount" && $user->rights->propal->creer) {
|
||||
}
|
||||
|
||||
// Add line
|
||||
else if (($action == 'addline' || $action == 'addline_predef') && $user->rights->propal->creer) {
|
||||
else if ($action == 'addline' && $user->rights->propal->creer) {
|
||||
|
||||
// Set if we used free entry or predefined product
|
||||
if (GETPOST('addline_libre')
|
||||
|| (GETPOST('dp_desc') && ! GETPOST('addline_libre') && ! GETPOST('idprod', 'int')>0) // we push enter onto qty field
|
||||
)
|
||||
$predef='';
|
||||
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
|
||||
if (GETPOST('prod_entry_mode') == 'free')
|
||||
{
|
||||
$predef='';
|
||||
$idprod=0;
|
||||
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
|
||||
$price_ht = GETPOST('price_ht');
|
||||
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||
}
|
||||
if (GETPOST('addline_predefined')
|
||||
|| (! GETPOST('dp_desc') && ! GETPOST('addline_predefined') && GETPOST('idprod', 'int')>0) // we push enter onto qty field
|
||||
)
|
||||
else
|
||||
{
|
||||
$predef=(($conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : '');
|
||||
$idprod=GETPOST('idprod', 'int');
|
||||
$product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):''));
|
||||
$price_ht = '';
|
||||
$tva_tx = '';
|
||||
}
|
||||
if (GETPOST('usenewaddlineform')) {
|
||||
$idprod = GETPOST('idprod', 'int');
|
||||
$product_desc = (GETPOST('product_desc') ? GETPOST('product_desc') : (GETPOST('np_desc') ? GETPOST('np_desc') : (GETPOST('dp_desc') ? GETPOST('dp_desc') : '')));
|
||||
$price_ht = GETPOST('price_ht');
|
||||
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||
}
|
||||
|
||||
$qty = GETPOST('qty' . $predef);
|
||||
$remise_percent = GETPOST('remise_percent' . $predef);
|
||||
|
||||
@ -587,7 +577,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
|
||||
$error ++;
|
||||
}
|
||||
|
||||
if ((empty($idprod) || GETPOST('usenewaddlineform')) && $price_ht == '') // Unit price can be 0 but not ''. Also price can be negative for
|
||||
if (empty($idprod) && $price_ht == '') // Unit price can be 0 but not ''. Also price can be negative for
|
||||
// proposal.
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors');
|
||||
@ -616,13 +606,6 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
|
||||
$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
|
||||
|
||||
// If prices fields are update
|
||||
if (GETPOST('usenewaddlineform')) {
|
||||
$pu_ht = price2num($price_ht, 'MU');
|
||||
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
|
||||
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
|
||||
$tva_tx = str_replace('*', '', $tva_tx);
|
||||
$desc = $product_desc;
|
||||
} else {
|
||||
$tva_tx = get_default_tva($mysoc, $object->client, $prod->id);
|
||||
$tva_npr = get_default_npr($mysoc, $object->client, $prod->id);
|
||||
|
||||
@ -706,7 +689,6 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
|
||||
$tmptxt .= ')';
|
||||
$desc = dol_concatdesc($desc, $tmptxt);
|
||||
}
|
||||
}
|
||||
|
||||
$type = $prod->type;
|
||||
} else {
|
||||
@ -756,6 +738,8 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
|
||||
propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
unset($_POST ['prod_entry_mode']);
|
||||
|
||||
unset($_POST ['qty']);
|
||||
unset($_POST ['type']);
|
||||
unset($_POST ['remise_percent']);
|
||||
@ -1798,32 +1782,18 @@ if ($action == 'create') {
|
||||
if (! empty($object->lines))
|
||||
$ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
|
||||
|
||||
// Form to add new line
|
||||
if ($object->statut == 0 && $user->rights->propal->creer) {
|
||||
if ($action != 'editline') {
|
||||
// Form to add new line
|
||||
if ($object->statut == 0 && $user->rights->propal->creer)
|
||||
{
|
||||
if ($action != 'editline')
|
||||
{
|
||||
$var = true;
|
||||
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL > 1)
|
||||
{
|
||||
// Add free or predefined products/services
|
||||
$object->formAddObjectLine(1, $mysoc, $soc);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add free products/services
|
||||
$object->formAddFreeProduct(1, $mysoc, $soc);
|
||||
|
||||
// Add predefined products/services
|
||||
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) {
|
||||
$var = ! $var;
|
||||
$object->formAddPredefinedProduct(1, $mysoc, $soc);
|
||||
}
|
||||
}
|
||||
// Add free products/services
|
||||
$object->formAddObjectLine(1, $mysoc, $soc);
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been
|
||||
// modified
|
||||
// by hook
|
||||
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
}
|
||||
}
|
||||
|
||||
@ -1833,9 +1803,10 @@ if ($action == 'create') {
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
if ($action == 'statut') {
|
||||
if ($action == 'statut')
|
||||
{
|
||||
/*
|
||||
* Formulaire cloture (signe ou non)
|
||||
* Form to close proposal (signed or not)
|
||||
*/
|
||||
$form_close = '<form action="' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id . '" method="post">';
|
||||
$form_close .= '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
|
||||
@ -1956,7 +1927,8 @@ if ($action == 'create') {
|
||||
}
|
||||
print "<br>\n";
|
||||
|
||||
if ($action != 'presend') {
|
||||
if ($action != 'presend')
|
||||
{
|
||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||
// print '<table width="100%"><tr><td width="50%" valign="top">';
|
||||
// print '<a name="builddoc"></a>'; // ancre
|
||||
@ -1993,9 +1965,9 @@ if ($action == 'create') {
|
||||
|
||||
/*
|
||||
* Action presend
|
||||
*
|
||||
*/
|
||||
if ($action == 'presend') {
|
||||
*/
|
||||
if ($action == 'presend')
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/'));
|
||||
|
||||
@ -479,32 +479,21 @@ else if ($action == 'addline' && $user->rights->commande->creer) {
|
||||
$error = false;
|
||||
|
||||
// Set if we used free entry or predefined product
|
||||
if (GETPOST('addline_libre')
|
||||
|| (GETPOST('dp_desc') && ! GETPOST('addline_libre') && ! GETPOST('idprod', 'int')>0) // we push enter onto qty field
|
||||
)
|
||||
$predef='';
|
||||
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
|
||||
if (GETPOST('prod_entry_mode') == 'free')
|
||||
{
|
||||
$predef='';
|
||||
$idprod=0;
|
||||
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
|
||||
$price_ht = GETPOST('price_ht');
|
||||
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||
}
|
||||
if (GETPOST('addline_predefined')
|
||||
|| (! GETPOST('dp_desc') && ! GETPOST('addline_predefined') && GETPOST('idprod', 'int')>0) // we push enter onto qty field
|
||||
)
|
||||
else
|
||||
{
|
||||
$predef=(($conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : '');
|
||||
$idprod=GETPOST('idprod', 'int');
|
||||
$product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):''));
|
||||
$price_ht = '';
|
||||
$tva_tx = '';
|
||||
}
|
||||
if (GETPOST('usenewaddlineform')) {
|
||||
$idprod = GETPOST('idprod', 'int');
|
||||
$product_desc = (GETPOST('product_desc') ? GETPOST('product_desc') : (GETPOST('np_desc') ? GETPOST('np_desc') : (GETPOST('dp_desc') ? GETPOST('dp_desc') : '')));
|
||||
$price_ht = GETPOST('price_ht');
|
||||
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||
}
|
||||
|
||||
$qty = GETPOST('qty' . $predef);
|
||||
$remise_percent = GETPOST('remise_percent' . $predef);
|
||||
|
||||
@ -520,7 +509,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) {
|
||||
}
|
||||
}
|
||||
|
||||
if ((empty($idprod) || GETPOST('usenewaddlineform')) && ($price_ht < 0) && ($qty < 0)) {
|
||||
if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) {
|
||||
setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors');
|
||||
$error ++;
|
||||
}
|
||||
@ -528,7 +517,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) {
|
||||
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors');
|
||||
$error ++;
|
||||
}
|
||||
if ((empty($idprod) || GETPOST('usenewaddlineform')) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not ''
|
||||
if (empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not ''
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors');
|
||||
$error ++;
|
||||
@ -559,13 +548,6 @@ else if ($action == 'addline' && $user->rights->commande->creer) {
|
||||
$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
|
||||
|
||||
// Update if prices fields are defined
|
||||
if (GETPOST('usenewaddlineform')) {
|
||||
$pu_ht = price2num($price_ht, 'MU');
|
||||
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
|
||||
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
|
||||
$tva_tx = str_replace('*', '', $tva_tx);
|
||||
$desc = $product_desc;
|
||||
} else {
|
||||
$tva_tx = get_default_tva($mysoc, $object->client, $prod->id);
|
||||
$tva_npr = get_default_npr($mysoc, $object->client, $prod->id);
|
||||
|
||||
@ -649,7 +631,6 @@ else if ($action == 'addline' && $user->rights->commande->creer) {
|
||||
$tmptxt .= ')';
|
||||
$desc = dol_concatdesc($desc, $tmptxt);
|
||||
}
|
||||
}
|
||||
|
||||
$type = $prod->type;
|
||||
} else {
|
||||
@ -700,6 +681,8 @@ else if ($action == 'addline' && $user->rights->commande->creer) {
|
||||
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
unset($_POST ['prod_entry_mode']);
|
||||
|
||||
unset($_POST ['qty']);
|
||||
unset($_POST ['type']);
|
||||
unset($_POST ['remise_percent']);
|
||||
@ -2098,30 +2081,17 @@ if ($action == 'create' && $user->rights->commande->creer) {
|
||||
/*
|
||||
* Form to add new line
|
||||
*/
|
||||
if ($object->statut == 0 && $user->rights->commande->creer) {
|
||||
if ($action != 'editline') {
|
||||
if ($object->statut == 0 && $user->rights->commande->creer)
|
||||
{
|
||||
if ($action != 'editline')
|
||||
{
|
||||
$var = true;
|
||||
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL > 1)
|
||||
{
|
||||
// Add free or predefined products/services
|
||||
$object->formAddObjectLine(1, $mysoc, $soc);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add free products/services
|
||||
$object->formAddFreeProduct(1, $mysoc, $soc);
|
||||
|
||||
// Add predefined products/services
|
||||
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) {
|
||||
$var = ! $var;
|
||||
$object->formAddPredefinedProduct(1, $mysoc, $soc);
|
||||
}
|
||||
}
|
||||
// Add free products/services
|
||||
$object->formAddObjectLine(1, $mysoc, $soc);
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been
|
||||
// modified by hook
|
||||
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
}
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
@ -1037,39 +1037,27 @@ else if ($action == 'add' && $user->rights->facture->creer)
|
||||
}
|
||||
|
||||
// Add a new line
|
||||
else if (($action == 'addline' || $action == 'addline_predef') && $user->rights->facture->creer)
|
||||
else if ($action == 'addline' && $user->rights->facture->creer)
|
||||
{
|
||||
$langs->load('errors');
|
||||
$error = 0;
|
||||
|
||||
// Set if we used free entry or predefined product
|
||||
if (GETPOST('addline_libre')
|
||||
|| (GETPOST('dp_desc') && ! GETPOST('addline_libre') && ! GETPOST('idprod', 'int')>0) // we push enter onto qty field
|
||||
)
|
||||
$predef='';
|
||||
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
|
||||
if (GETPOST('prod_entry_mode') == 'free')
|
||||
{
|
||||
$predef = '';
|
||||
$idprod = 0;
|
||||
$product_desc = (GETPOST('dp_desc') ? GETPOST('dp_desc') : '');
|
||||
$idprod=0;
|
||||
$price_ht = GETPOST('price_ht');
|
||||
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||
}
|
||||
if (GETPOST('addline_predefined')
|
||||
|| (! GETPOST('dp_desc') && ! GETPOST('addline_predefined') && GETPOST('idprod', 'int')>0) // we push enter onto qty field
|
||||
)
|
||||
else
|
||||
{
|
||||
$predef = (($conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : '');
|
||||
$idprod = GETPOST('idprod', 'int');
|
||||
$product_desc = (GETPOST('product_desc') ? GETPOST('product_desc') : (GETPOST('np_desc') ? GETPOST('np_desc') : ''));
|
||||
$idprod=GETPOST('idprod', 'int');
|
||||
$price_ht = '';
|
||||
$tva_tx = '';
|
||||
}
|
||||
if (GETPOST('usenewaddlineform')) // TODO Remove this
|
||||
{
|
||||
$idprod = GETPOST('idprod', 'int');
|
||||
$product_desc = (GETPOST('product_desc') ? GETPOST('product_desc') : (GETPOST('np_desc') ? GETPOST('np_desc') : (GETPOST('dp_desc') ? GETPOST('dp_desc') : '')));
|
||||
$price_ht = GETPOST('price_ht');
|
||||
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||
}
|
||||
|
||||
$qty = GETPOST('qty' . $predef);
|
||||
$remise_percent = GETPOST('remise_percent' . $predef);
|
||||
|
||||
@ -1085,7 +1073,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
|
||||
}
|
||||
}
|
||||
|
||||
if ((empty($idprod) || GETPOST('usenewaddlineform')) && ($price_ht < 0) && ($qty < 0)) {
|
||||
if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) {
|
||||
setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors');
|
||||
$error ++;
|
||||
}
|
||||
@ -1093,7 +1081,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
|
||||
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors');
|
||||
$error ++;
|
||||
}
|
||||
if ((empty($idprod) || GETPOST('usenewaddlineform')) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not ''
|
||||
if (empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not ''
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors');
|
||||
$error ++;
|
||||
@ -1135,13 +1123,6 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
|
||||
$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
|
||||
|
||||
// Update if prices fields are defined
|
||||
if (GETPOST('usenewaddlineform')) {
|
||||
$pu_ht = price2num($price_ht, 'MU');
|
||||
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
|
||||
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
|
||||
$tva_tx = str_replace('*', '', $tva_tx);
|
||||
$desc = $product_desc;
|
||||
} else {
|
||||
$tva_tx = get_default_tva($mysoc, $object->client, $prod->id);
|
||||
$tva_npr = get_default_npr($mysoc, $object->client, $prod->id);
|
||||
|
||||
@ -1225,7 +1206,6 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
|
||||
$tmptxt .= ')';
|
||||
$desc = dol_concatdesc($desc, $tmptxt);
|
||||
}
|
||||
}
|
||||
|
||||
$type = $prod->type;
|
||||
} else {
|
||||
@ -1273,6 +1253,8 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
|
||||
facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
unset($_POST ['prod_entry_mode']);
|
||||
|
||||
unset($_POST['qty']);
|
||||
unset($_POST['type']);
|
||||
unset($_POST['remise_percent']);
|
||||
@ -3303,30 +3285,19 @@ if ($action == 'create')
|
||||
if (! empty($object->lines))
|
||||
$ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
|
||||
|
||||
// Form to add new line
|
||||
if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline') {
|
||||
$var = true;
|
||||
// Form to add new line
|
||||
if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline')
|
||||
{
|
||||
if ($action != 'editline')
|
||||
{
|
||||
$var = true;
|
||||
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL > 1)
|
||||
{
|
||||
// Add free or predefined products/services
|
||||
$object->formAddObjectLine(1, $mysoc, $soc);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add free products/services
|
||||
$object->formAddFreeProduct(1, $mysoc, $soc);
|
||||
$object->formAddObjectLine(1, $mysoc, $soc);
|
||||
|
||||
// Add predefined products/services
|
||||
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) {
|
||||
$var = ! $var;
|
||||
$object->formAddPredefinedProduct(1, $mysoc, $soc);
|
||||
}
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by
|
||||
// hook
|
||||
}
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
@ -355,28 +355,21 @@ else if ($action == 'classin' && $user->rights->contrat->creer)
|
||||
else if ($action == 'addline' && $user->rights->contrat->creer)
|
||||
{
|
||||
// Set if we used free entry or predefined product
|
||||
if (GETPOST('addline_libre'))
|
||||
$predef='';
|
||||
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
|
||||
if (GETPOST('prod_entry_mode') == 'free')
|
||||
{
|
||||
$predef='';
|
||||
$idprod=0;
|
||||
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
|
||||
$price_ht = GETPOST('price_ht');
|
||||
$tva_tx=(GETPOST('tva_tx')?GETPOST('tva_tx'):0);
|
||||
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
||||
}
|
||||
if (GETPOST('addline_predefined'))
|
||||
else
|
||||
{
|
||||
$predef=(($conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : '');
|
||||
$idprod=GETPOST('idprod', 'int');
|
||||
$product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):''));
|
||||
$price_ht = '';
|
||||
$tva_tx = '';
|
||||
}
|
||||
if (GETPOST('usenewaddlineform')) {
|
||||
$idprod=GETPOST('idprod', 'int');
|
||||
$product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):(GETPOST('dp_desc')?GETPOST('dp_desc'):'')));
|
||||
$price_ht = GETPOST('price_ht');
|
||||
$tva_tx=(GETPOST('tva_tx')?GETPOST('tva_tx'):0);
|
||||
}
|
||||
|
||||
$qty = GETPOST('qty'.$predef);
|
||||
$remise_percent=GETPOST('remise_percent'.$predef);
|
||||
|
||||
@ -520,6 +513,8 @@ else if ($action == 'addline' && $user->rights->contrat->creer)
|
||||
}
|
||||
*/
|
||||
|
||||
unset($_POST ['prod_entry_mode']);
|
||||
|
||||
unset($_POST['qty']);
|
||||
unset($_POST['type']);
|
||||
unset($_POST['remise_percent']);
|
||||
@ -1161,7 +1156,12 @@ else
|
||||
$productstatic->type=$objp->ptype;
|
||||
$productstatic->ref=$objp->pref;
|
||||
print $productstatic->getNomUrl(1,'',20);
|
||||
print $objp->label?' - '.dol_trunc($objp->label,16):'';
|
||||
if ($objp->label)
|
||||
{
|
||||
print ' - ';
|
||||
$productstatic->ref=$objp->label;
|
||||
print $productstatic->getNomUrl(0,'',16);
|
||||
}
|
||||
if ($objp->description) print '<br>'.dol_nl2br($objp->description);
|
||||
print '</td>';
|
||||
}
|
||||
@ -1561,34 +1561,19 @@ else
|
||||
|
||||
// Trick to not show product entries
|
||||
$savproductenabled=$conf->product->enabled;
|
||||
$conf->product->enabled = 0;
|
||||
if (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $conf->product->enabled = 0;
|
||||
|
||||
// Form to add new line
|
||||
if ($action != 'editline')
|
||||
{
|
||||
$var=true;
|
||||
if ($action != 'editline')
|
||||
{
|
||||
$var = true;
|
||||
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL > 1)
|
||||
{
|
||||
// Add free or predefined products/services
|
||||
$object->formAddObjectLine($dateSelector,$mysoc,$object->thirdparty);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add free products/services
|
||||
$object->formAddFreeProduct($dateSelector,$mysoc,$object->thirdparty);
|
||||
// Add free products/services
|
||||
$object->formAddObjectLine(1, $mysoc, $soc);
|
||||
|
||||
// Add predefined products/services
|
||||
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
|
||||
{
|
||||
$var=!$var;
|
||||
$object->formAddPredefinedProduct($dateSelector,$mysoc,$object->thirdparty);
|
||||
}
|
||||
}
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
}
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
}
|
||||
|
||||
// Restore correct setup
|
||||
$conf->product->enabled = $savproductenabled;
|
||||
|
||||
@ -2668,61 +2668,8 @@ abstract class CommonObject
|
||||
|
||||
/* This is to show add lines */
|
||||
|
||||
/**
|
||||
* Show add predefined products/services form
|
||||
* TODO Edit templates to use global variables and include them directly in controller call
|
||||
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
|
||||
*
|
||||
* @param int $dateSelector 1=Show also date range input fields
|
||||
* @param Societe $seller Object thirdparty who sell
|
||||
* @param Societe $buyer Object thirdparty who buy
|
||||
* @return void
|
||||
* @deprecated
|
||||
*/
|
||||
function formAddPredefinedProduct($dateSelector,$seller,$buyer)
|
||||
{
|
||||
global $conf,$langs,$object,$hookmanager;
|
||||
global $form,$bcnd,$var;
|
||||
global $user;
|
||||
//Line extrafield
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$extrafieldsline = new ExtraFields($this->db);
|
||||
$extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line);
|
||||
|
||||
// Use global variables + $dateSelector + $seller and $buyer
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_create.tpl.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show add free products/services form
|
||||
* TODO Edit templates to use global variables and include them directly in controller call
|
||||
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
|
||||
*
|
||||
* @param int $dateSelector 1=Show also date range input fields (start and end date)
|
||||
* @param Societe $seller Object thirdparty who sell
|
||||
* @param Societe $buyer Object thirdparty who buy
|
||||
* @return void
|
||||
*/
|
||||
function formAddFreeProduct($dateSelector,$seller,$buyer)
|
||||
{
|
||||
global $conf,$langs,$object,$hookmanager;
|
||||
global $form,$bcnd,$var;
|
||||
global $user;
|
||||
|
||||
//Line extrafield
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$extrafieldsline = new ExtraFields($this->db);
|
||||
$extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line);
|
||||
|
||||
// Use global variables + $dateSelector + $seller and $buyer
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_create.tpl.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show add free and predefined products/services form
|
||||
* TODO Edit templates to use global variables and include them directly in controller call
|
||||
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
|
||||
*
|
||||
* @param int $dateSelector 1=Show also date range input fields
|
||||
* @param Societe $seller Object thirdparty who sell
|
||||
@ -2744,7 +2691,7 @@ abstract class CommonObject
|
||||
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
|
||||
foreach($dirtpls as $reldir)
|
||||
{
|
||||
$tpl = dol_buildpath($reldir.'/objectline_add.tpl.php');
|
||||
$tpl = dol_buildpath($reldir.'/objectline_create.tpl.php');
|
||||
if (empty($conf->file->strict_mode)) {
|
||||
$res=@include $tpl;
|
||||
} else {
|
||||
|
||||
@ -1,694 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
* Need to have following variables defined:
|
||||
* $conf
|
||||
* $langs
|
||||
* $dateSelector
|
||||
* $this (invoice, order, ...)
|
||||
* $line defined
|
||||
*/
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE objectline_add.tpl.php -->
|
||||
<tr class="liste_titre nodrag nodrop">
|
||||
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>><div id="add"></div><?php echo $langs->trans('AddNewLine'); ?></td>
|
||||
<td align="right" width="50"><?php echo $langs->trans('VAT'); ?></td>
|
||||
<td align="right" width="80"><?php echo $langs->trans('PriceUHT'); ?></td>
|
||||
<td align="right" width="80"><?php echo $langs->trans('PriceUTTC'); ?></td>
|
||||
<td align="right" width="50"><?php echo $langs->trans('Qty'); ?></td>
|
||||
<td align="right" width="50"><?php echo $langs->trans('ReductionShort'); ?></td>
|
||||
<?php
|
||||
$colspan = 4;
|
||||
$colspan2 = 12;
|
||||
if (! empty($conf->margin->enabled)) {
|
||||
?>
|
||||
<td align="right"><?php echo $langs->trans('BuyingPrice'); ?></td>
|
||||
<?php
|
||||
if ($user->rights->margins->creer)
|
||||
{
|
||||
if(! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
{
|
||||
echo '<td align="right">'.$langs->trans('MarginRate').'</td>';
|
||||
}
|
||||
if(! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
{
|
||||
echo '<td align="right">'.$langs->trans('MarkRate').'</td>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
$colspan++;
|
||||
$colspan2++;
|
||||
}
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
$colspan++;
|
||||
$colspan2++;
|
||||
}
|
||||
}
|
||||
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
|
||||
$colspan2++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<td colspan="<?php echo $colspan; ?>"> </td>
|
||||
</tr>
|
||||
|
||||
<form name="addproduct" id="addproduct" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id; ?>#add" method="POST">
|
||||
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
|
||||
<input type="hidden" name="action" value="addline" />
|
||||
<input type="hidden" name="usenewaddlineform" value="1" />
|
||||
<input type="hidden" name="id" value="<?php echo $this->id; ?>" />
|
||||
|
||||
<?php if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { ?>
|
||||
<tr class="liste_titre nodrag nodrop">
|
||||
<td colspan="<?php echo $colspan2; ?>">
|
||||
<?php
|
||||
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
|
||||
{
|
||||
// show/hide, update elements after select
|
||||
$ajaxoptions=array(
|
||||
'update' => array(
|
||||
'select_type' => 'type',
|
||||
'product_ref' => 'value',
|
||||
'product_label' => 'label2',
|
||||
'price_base_type' => 'pricebasetype',
|
||||
'price_ht' => 'price_ht',
|
||||
'origin_price_ht_cache' => 'price_ht',
|
||||
'origin_tva_tx_cache' => 'tva_tx',
|
||||
'origin_price_ttc_cache' => 'price_ttc',
|
||||
'qty' => 'qty',
|
||||
'remise_percent' => 'discount'
|
||||
),
|
||||
'update_textarea' => array(
|
||||
'product_desc' => 'desc'
|
||||
),
|
||||
//'show' => array(
|
||||
//'price_base_type_area'
|
||||
//),
|
||||
'disabled' => array(
|
||||
'select_type'
|
||||
)
|
||||
);
|
||||
$form->select_produits('', 'idprod', '', $conf->product->limit_size, $buyer->price_level, 1, 2, '', 3, $ajaxoptions,$buyer->id);
|
||||
}
|
||||
?>
|
||||
<span id="add_product_area" class="hideobject"> | <input type="checkbox" id="add_product_checkbox" name="add_product" value="1" />
|
||||
<span id="add_product_text" class="hideobject">
|
||||
<?php echo $form->textwithtooltip($langs->trans('AddThisProductCard'), $langs->trans('HelpAddThisProductCard'),1,0,'','',3); ?>
|
||||
</span>
|
||||
<span id="add_service_text" class="hideobject">
|
||||
<?php echo $form->textwithtooltip($langs->trans('AddThisServiceCard'), $langs->trans('HelpAddThisServiceCard'),1,0,'','',3); ?>
|
||||
</span>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
<tr <?php echo $bcnd[$var]; ?>>
|
||||
<td colspan="<?php echo $colspan2; ?>">
|
||||
<?php echo $form->select_type_of_lines((GETPOST('type')?GETPOST('type'):-1), 'type', 1); ?>
|
||||
|
||||
<span id="product_ref_area" class="hideobject">
|
||||
<label for="product_ref"><?php echo $langs->trans("Ref"); ?></label>
|
||||
<input id="product_ref" name="product_ref" size="20" value="<?php echo GETPOST('product_ref'); ?>">
|
||||
</span>
|
||||
<span id="product_label_area">
|
||||
<label for="product_label"><?php echo $langs->trans("Label"); ?></label>
|
||||
<input id="product_label" name="product_label" size="40" value="<?php echo GETPOST('product_label'); ?>">
|
||||
</span>
|
||||
<span id="price_base_type_area" class="hideobject">
|
||||
<input type="hidden" id="price_base_type" name="price_base_type" value="" /> | <?php echo $langs->trans('PriceBase'); ?>:
|
||||
<span id="view_price_base_type"></span>
|
||||
</span>
|
||||
<?php
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters=array('fk_parent_line'=>GETPOST('fk_parent_line'));
|
||||
$reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
|
||||
<tr <?php echo $bcnd[$var]; ?>>
|
||||
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
|
||||
|
||||
<?php
|
||||
// Editor wysiwyg
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$nbrows=ROWS_2;
|
||||
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
|
||||
$enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
|
||||
$doleditor=new DolEditor('product_desc', GETPOST('product_desc'), '', 150, 'dolibarr_details', '', false, true, $enable, $nbrows, 70);
|
||||
$doleditor->Create();
|
||||
?>
|
||||
</td>
|
||||
|
||||
<td align="right">
|
||||
<?php echo $form->load_tva('tva_tx', (GETPOST('tva_tx')?GETPOST('tva_tx'):-1), $seller, $buyer); ?>
|
||||
<input type="hidden" id="origin_tva_tx_cache" name="origin_tva_tx_cache" value="" />
|
||||
</td>
|
||||
<td align="right">
|
||||
<input type="text" size="8" id="price_ht" name="price_ht" value="<?php echo (GETPOST('price_ht')?GETPOST('price_ht'):''); ?>">
|
||||
<input type="hidden" id="origin_price_ht_cache" name="origin_price_ht_cache" value="" />
|
||||
</td>
|
||||
<td align="right">
|
||||
<input type="text" size="8" id="price_ttc" name="price_ttc" value="<?php echo (GETPOST('price_ttc')?GETPOST('price_ttc'):''); ?>">
|
||||
<input type="hidden" id="origin_price_ttc_cache" name="origin_price_ttc_cache" value="" />
|
||||
</td>
|
||||
<td align="right"><input type="text" size="3" id="qty" name="qty" value="<?php echo (GETPOST('qty')?GETPOST('qty'):1); ?>"></td>
|
||||
<td align="right" class="nowrap">
|
||||
<input type="text" size="1" value="<?php echo $buyer->remise_percent; ?>" id="remise_percent" name="remise_percent">%
|
||||
<input type="hidden" id="origin_remise_percent" name="origin_remise_percent" value="<?php echo $buyer->remise_percent; ?>" />
|
||||
</td>
|
||||
<?php
|
||||
$colspan = 4;
|
||||
if (! empty($conf->margin->enabled)) {
|
||||
?>
|
||||
<td align="right">
|
||||
<select id="fournprice" name="fournprice" style="display: none;"></select>
|
||||
<input type="text" size="5" id="buying_price" name="buying_price" value="<?php echo (GETPOST('buying_price')?GETPOST('buying_price'):''); ?>">
|
||||
</td>
|
||||
<?php
|
||||
if ($user->rights->margins->creer)
|
||||
{
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
echo '<td align="right" class="nowrap"><input type="text" size="2" name="np_marginRate" value="'.(isset($_POST["np_marginRate"])?$_POST["np_marginRate"]:'').'">%</td>';
|
||||
}
|
||||
elseif (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
echo '<td align="right" class="nowrap"><input type="text" size="2" name="np_markRate" value="'.(isset($_POST["np_markRate"])?$_POST["np_markRate"]:'').'">%</td>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
$colspan++;
|
||||
}
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
$colspan++;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<td align="center" valign="middle" colspan="<?php echo $colspan; ?>"><input type="submit" class="button" id="addlinebutton" name="addline" value="<?php echo $langs->trans('Add'); ?>"></td>
|
||||
<?php
|
||||
if (!empty($extrafieldsline)) {
|
||||
if ($this->table_element_line=='commandedet') {
|
||||
$newline = new OrderLine($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='propaldet') {
|
||||
$newline = new PropaleLigne($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='facturedet') {
|
||||
$newline = new FactureLigne($this->db);
|
||||
}
|
||||
if (is_object($newline)) {
|
||||
print $newline->showOptionals($extrafieldsline,'edit',array('style'=>$bcnd[$var],'colspan'=>$coldisplay+8));
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
|
||||
|
||||
<?php if (! empty($conf->service->enabled) && ! empty($dateSelector)) {
|
||||
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
|
||||
$colspan = 12;
|
||||
else
|
||||
$colspan = 11;
|
||||
|
||||
?>
|
||||
<tr id="service_duration_area" <?php echo $bcnd[$var]; ?>>
|
||||
<td colspan="<?php echo $colspan; ?>">
|
||||
<?php
|
||||
$hourmin=(isset($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:'');
|
||||
echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
|
||||
echo $form->select_date('','date_start',$hourmin,$hourmin,1,"addproduct");
|
||||
echo ' '.$langs->trans('to').' ';
|
||||
echo $form->select_date('','date_end',$hourmin,$hourmin,1,"addproduct");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
|
||||
// Add line button disabled by default
|
||||
$('#addlinebutton').attr('disabled','disabled');
|
||||
|
||||
// Service duration hide by default
|
||||
$('#service_duration_area').hide();
|
||||
|
||||
$('#idprod').change(function() {
|
||||
if ($(this).val() > 0) {
|
||||
|
||||
// Update vat rate combobox
|
||||
getVATRates('getSellerVATRates', 'tva_tx', $(this).val());
|
||||
|
||||
// For compatibility with combobox
|
||||
<?php if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { ?>
|
||||
$.post('<?php echo DOL_URL_ROOT; ?>/product/ajax/products.php', {
|
||||
'action': 'fetch',
|
||||
'id': $(this).val(),
|
||||
'price_level': <?php echo empty($buyer->price_level)?1:$buyer->price_level; ?>,
|
||||
'pbq': $("option:selected", this).attr('pbq')
|
||||
<?php if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {?>
|
||||
,'socid': <?php echo $buyer->id; ?>
|
||||
<?php }?>
|
||||
},
|
||||
function(data) {
|
||||
if (typeof data != 'undefined') {
|
||||
$('#product_ref').val(data.ref);
|
||||
$('#product_label').val(data.label);
|
||||
$('#origin_tva_tx_cache').val(data.tva_tx);
|
||||
$('#price_base_type').val(data.pricebasetype).trigger('change');
|
||||
$('#price_ht').val(data.price_ht).trigger('change');
|
||||
$('#origin_price_ht_cache').val(data.price_ht);
|
||||
//$('#origin_price_ttc_cache').val(data.price_ttc);
|
||||
$('#select_type').val(data.type).attr('disabled','disabled').trigger('change');
|
||||
//$('#price_base_type_area').show();
|
||||
$('#qty').val(data.qty);
|
||||
if($('#remise_percent').val() < data.discount) $('#remise_percent').val(data.discount);
|
||||
|
||||
if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined" && CKEDITOR.instances['product_desc'] != "undefined") {
|
||||
CKEDITOR.instances['product_desc'].setData(data.desc).focus();
|
||||
} else {
|
||||
$("#product_desc").html(data.desc).focus();
|
||||
}
|
||||
}
|
||||
}, 'json');
|
||||
<?php } ?>
|
||||
|
||||
} else {
|
||||
|
||||
$('#price_ttc').val('');
|
||||
|
||||
// For compatibility with combobox
|
||||
<?php if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { ?>
|
||||
$('#select_type').val('').removeAttr('disabled').trigger('change');
|
||||
$('#product_ref').val('');
|
||||
$('#product_label').val('');
|
||||
$('#price_ht').val('').trigger('change');
|
||||
$('#origin_price_ht_cache').val('');
|
||||
//$('#origin_price_ttc_cache').val('');
|
||||
$('#origin_tva_tx_cache').val('');
|
||||
$('#price_base_type').val('');
|
||||
$('#price_base_type_area').hide();
|
||||
|
||||
if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined" && CKEDITOR.instances['product_desc'] != "undefined") {
|
||||
CKEDITOR.instances['product_desc'].setData('');
|
||||
} else {
|
||||
$("#product_desc").html('');
|
||||
}
|
||||
<?php } ?>
|
||||
}
|
||||
});
|
||||
|
||||
$('#select_type').change(function() {
|
||||
var type = $(this).val();
|
||||
if (type >= 0) {
|
||||
if (type == 0) {
|
||||
$('#add_product_text').show();
|
||||
$('#add_service_text').hide();
|
||||
$('#service_duration_area').hide();
|
||||
$('#date_start').val('').trigger('change');
|
||||
$('#date_end').val('').trigger('change');
|
||||
} else if (type == 1) {
|
||||
$('#add_product_text').hide();
|
||||
$('#add_service_text').show();
|
||||
$('#service_duration_area').show();
|
||||
}
|
||||
//$('#add_product_area').show(); // TODO for add product card
|
||||
var addline=false;
|
||||
if ($('#price_ht').val().length > 0) {
|
||||
if ($('#idprod').val() == 0) {
|
||||
if (typeof CKEDITOR == 'object' && typeof CKEDITOR.instances != 'undefined' && CKEDITOR.instances['product_desc'] != 'undefined') {
|
||||
var content = CKEDITOR.instances['product_desc'].getData();
|
||||
} else {
|
||||
var content = $('#product_desc').val();
|
||||
}
|
||||
if (content.length > 0) {
|
||||
addline=true;
|
||||
}
|
||||
} else {
|
||||
addline=true;
|
||||
}
|
||||
}
|
||||
if (addline) {
|
||||
$('#addlinebutton').removeAttr('disabled');
|
||||
} else {
|
||||
$('#addlinebutton').attr('disabled','disabled');
|
||||
}
|
||||
} else {
|
||||
//$('#add_product_area').hide(); // TODO for add product card
|
||||
$('#add_product_checkbox').removeAttr('checked').trigger('change');
|
||||
$('#addlinebutton').attr('disabled','disabled');
|
||||
$('#service_duration_area').hide();
|
||||
$('#date_start').val('').trigger('change');
|
||||
$('#date_end').val('').trigger('change');
|
||||
}
|
||||
});
|
||||
|
||||
// TODO for add product card
|
||||
$('#add_product_checkbox').change(function() {
|
||||
if ($(this).attr('checked')) {
|
||||
$('#product_ref_area').show();
|
||||
$('#product_ref').focus();
|
||||
$('#product_label').removeAttr('disabled');
|
||||
$('#search_idprod').attr('disabled','disabled');
|
||||
$('#update_label_area').hide();
|
||||
$('#update_label_checkbox').removeAttr('checked');
|
||||
} else {
|
||||
if ($("#idprod").val() > 0) {
|
||||
$('#update_label_area').show();
|
||||
$('#product_label').attr('disabled', 'disabled');
|
||||
}
|
||||
$('#product_ref_area').hide();
|
||||
$('#search_idprod').removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
|
||||
$('#price_ht').focusin(function() {
|
||||
$('#price_base_type').val('HT').trigger('change');
|
||||
});
|
||||
|
||||
$('#price_ttc').focusin(function() {
|
||||
$('#price_base_type').val('TTC').trigger('change');
|
||||
});
|
||||
|
||||
$('#price_base_type').change(function() {
|
||||
$('#view_price_base_type').html($(this).val());
|
||||
});
|
||||
|
||||
$('#price_ht').bind('change keyup input', function() {
|
||||
if (($('#idprod').val() == 0 && $('#price_base_type').val() == 'HT') || $('#idprod').val() > 0) {
|
||||
update_price('price_ht', 'price_ttc');
|
||||
}
|
||||
});
|
||||
|
||||
$('#price_ttc').bind('change keyup input', function() {
|
||||
if ($('#price_base_type').val() == 'TTC') {
|
||||
update_price('price_ttc', 'price_ht');
|
||||
}
|
||||
});
|
||||
|
||||
if ($('#idprod').val() == 0 && $('#tva_tx').val() == 0) {
|
||||
$('#price_ttc').attr('disabled','disabled');
|
||||
}
|
||||
|
||||
$('#remise_percent').bind('change', function() {
|
||||
if ($(this).val() < $('#origin_remise_percent').val())
|
||||
$('#remise_percent').val($('#origin_remise_percent').val());
|
||||
});
|
||||
|
||||
$('#tva_tx').change(function() {
|
||||
if ($(this).val() == 0) {
|
||||
if ($('#idprod').val() == 0) {
|
||||
$('#price_ttc').attr('disabled','disabled');
|
||||
}
|
||||
$('#price_ttc').val('');
|
||||
} else {
|
||||
// Enable excl.VAT field
|
||||
$('#price_ttc').removeAttr('disabled');
|
||||
// Update prices fields
|
||||
if ($('#price_base_type').val() == 'HT') {
|
||||
update_price('price_ht', 'price_ttc');
|
||||
} else if ($('#price_base_type').val() == 'TTC') {
|
||||
update_price('price_ttc', 'price_ht');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function update_price(input, output) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '<?php echo DOL_URL_ROOT; ?>/core/ajax/price.php',
|
||||
data: {
|
||||
'amount': $('#' + input).val(),
|
||||
'output': output,
|
||||
'tva_tx': $('#tva_tx').val()
|
||||
},
|
||||
success: function(data) {
|
||||
var addline=false;
|
||||
if (typeof data[output] != 'undefined') {
|
||||
// Hide price_ttc if no vat
|
||||
//if ($('#tva_tx').val() > 0 || ($('#tva_tx').val() == 0 && output == 'price_ht')) {
|
||||
$('#' + output).val(data[output]);
|
||||
//}
|
||||
if ($('#idprod').val() == 0 && $('#select_type').val() >= 0) {
|
||||
if (typeof CKEDITOR == 'object' && typeof CKEDITOR.instances != 'undefined' && CKEDITOR.instances['product_desc'] != 'undefined') {
|
||||
var content = CKEDITOR.instances['product_desc'].getData();
|
||||
} else {
|
||||
var content = $('#product_desc').val();
|
||||
}
|
||||
if (content.length > 0) {
|
||||
addline=true;
|
||||
}
|
||||
} else {
|
||||
addline=true;
|
||||
}
|
||||
} else {
|
||||
$('#' + input).val('');
|
||||
$('#' + output).val('');
|
||||
}
|
||||
if (addline) {
|
||||
$('#addlinebutton').removeAttr('disabled');
|
||||
} else {
|
||||
$('#addlinebutton').attr('disabled','disabled');
|
||||
}
|
||||
},
|
||||
dataType: 'json',
|
||||
async: false});
|
||||
}
|
||||
|
||||
function getVATRates(action, htmlname, idprod) {
|
||||
var productid = (idprod?idprod:0);
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '<?php echo DOL_URL_ROOT;?>/core/ajax/vatrates.php',
|
||||
data: {
|
||||
'action': action,
|
||||
'id': <?php echo $buyer->id; ?>,
|
||||
'productid': productid,
|
||||
'htmlname': htmlname
|
||||
},
|
||||
success: function(data){
|
||||
if (typeof data != 'undefined' && data.error == null) {
|
||||
$("#" + htmlname).html(data.value).trigger('change');
|
||||
}
|
||||
},
|
||||
dataType: "json",
|
||||
async: false
|
||||
});
|
||||
}
|
||||
|
||||
// Check if decription is not empty for free line
|
||||
<?php if (! empty($conf->fckeditor->enabled) && ! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?>
|
||||
CKEDITOR.on('instanceReady', function() {
|
||||
CKEDITOR.instances['product_desc'].on('key', function() {
|
||||
var addline=false;
|
||||
if ($('#idprod').val() == 0 && $('#select_type').val() >= 0 && $('#price_ht').val().length > 0) {
|
||||
var content = CKEDITOR.instances['product_desc'].getData();
|
||||
if (content.length > 0) {
|
||||
addline=true;
|
||||
}
|
||||
} else if ($('#idprod').val() > 0 && $('#price_ht').val().length > 0) {
|
||||
addline=true;
|
||||
}
|
||||
if (addline) {
|
||||
$('#addlinebutton').removeAttr('disabled');
|
||||
} else {
|
||||
$('#addlinebutton').attr('disabled','disabled');
|
||||
}
|
||||
});
|
||||
});
|
||||
<?php } else { ?>
|
||||
$('#product_desc').keyup(function() {
|
||||
var addline=false;
|
||||
if ($('#idprod').val() == 0 && $('#select_type').val() >= 0 && $('#price_ht').val().length > 0) {
|
||||
var content = $('#product_desc').val();
|
||||
if (content.length > 0) {
|
||||
addline=true;
|
||||
}
|
||||
} else if ($('#idprod').val() > 0 && $('#price_ht').val().length > 0) {
|
||||
addline=true;
|
||||
}
|
||||
if (addline) {
|
||||
$('#addlinebutton').removeAttr('disabled');
|
||||
} else {
|
||||
$('#addlinebutton').attr('disabled','disabled');
|
||||
}
|
||||
});
|
||||
<?php } ?>
|
||||
|
||||
<?php if (! empty($conf->margin->enabled)) { ?>
|
||||
$("#idprod").change(function() {
|
||||
$("#fournprice").empty();
|
||||
$("#buying_price").show();
|
||||
if ($(this).val() > 0)
|
||||
{
|
||||
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': $(this).val()}, function(data) {
|
||||
if (data && data.length > 0) {
|
||||
var options = '';
|
||||
var i = 0;
|
||||
$(data).each(function() {
|
||||
i++;
|
||||
options += '<option value="'+this.id+'" title="'+this.title+'" price="'+this.price+'"';
|
||||
if (i == 1) {
|
||||
options += ' selected';
|
||||
$("#buying_price").val(this.price);
|
||||
}
|
||||
options += '>'+this.label+'</option>';
|
||||
});
|
||||
options += '<option value=null><?php echo $langs->trans("InputPrice"); ?></option>';
|
||||
$("#fournprice").html(options);
|
||||
$("#buying_price").hide();
|
||||
$("#fournprice").show();
|
||||
$("#fournprice").change(function() {
|
||||
var selval = $(this).find('option:selected').attr("price");
|
||||
if (selval)
|
||||
$("#buying_price").val(selval).hide();
|
||||
else
|
||||
$('#buying_price').show();
|
||||
});
|
||||
} else {
|
||||
$("#fournprice").hide();
|
||||
$('#buying_price').val('');
|
||||
}
|
||||
},
|
||||
'json');
|
||||
} else {
|
||||
$("#fournprice").hide();
|
||||
$('#buying_price').val('');
|
||||
}
|
||||
});
|
||||
var npRate = null;
|
||||
<?php
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
|
||||
npRate = "np_marginRate";
|
||||
<?php }
|
||||
elseif (! empty($conf->global->DISPLAY_MARK_RATES)) { ?>
|
||||
npRate = "np_markRate";
|
||||
<?php }
|
||||
?>
|
||||
|
||||
$("form#addproduct").submit(function(e) {
|
||||
if (npRate) return checkFreeLine(e, npRate);
|
||||
else return true;
|
||||
});
|
||||
if (npRate == 'np_marginRate') {
|
||||
$("input[name='np_marginRate']:first").blur(function(e) {
|
||||
return checkFreeLine(e, npRate);
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (npRate == 'np_markRate') {
|
||||
$("input[name='np_markRate']:first").blur(function(e) {
|
||||
return checkFreeLine(e, npRate);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function checkFreeLine(e, npRate)
|
||||
{
|
||||
var buying_price = $("input[name='buying_price']:first");
|
||||
var remise = $("input[name='remise_percent']:first");
|
||||
|
||||
var rate = $("input[name='"+npRate+"']:first");
|
||||
if (rate.val() == '')
|
||||
return true;
|
||||
if (! $.isNumeric(rate.val().replace(',','.')))
|
||||
{
|
||||
alert('<?php echo $langs->trans("rateMustBeNumeric"); ?>');
|
||||
e.stopPropagation();
|
||||
setTimeout(function () { rate.focus() }, 50);
|
||||
return false;
|
||||
}
|
||||
if (npRate == "np_markRate" && rate.val() >= 100)
|
||||
{
|
||||
alert('<?php echo $langs->trans("markRateShouldBeLesserThan100"); ?>');
|
||||
e.stopPropagation();
|
||||
setTimeout(function () { rate.focus() }, 50);
|
||||
return false;
|
||||
}
|
||||
|
||||
var price = 0;
|
||||
remisejs=price2numjs(remise.val());
|
||||
|
||||
if (remisejs != 100)
|
||||
{
|
||||
bpjs=price2numjs(buying_price.val());
|
||||
ratejs=price2numjs(rate.val());
|
||||
|
||||
if (npRate == "np_marginRate")
|
||||
price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
|
||||
else if (npRate == "np_markRate")
|
||||
price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
|
||||
}
|
||||
$("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value
|
||||
|
||||
update_price('price_ht', 'price_ttc');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Function similar to price2num in PHP */
|
||||
function price2numjs(num)
|
||||
{
|
||||
<?php
|
||||
$dec=','; $thousand=' ';
|
||||
if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal");
|
||||
if ($langs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->transnoentitiesnoconv("SeparatorThousand");
|
||||
if ($thousand == 'None') $thousand='';
|
||||
print "var dec='".$dec."'; var thousand='".$thousand."';\n";
|
||||
?>
|
||||
|
||||
var main_max_dec_shown = <?php echo $conf->global->MAIN_MAX_DECIMALS_SHOWN; ?>;
|
||||
var main_rounding_unit = <?php echo $conf->global->MAIN_MAX_DECIMALS_UNIT; ?>;
|
||||
var main_rounding_tot = <?php echo $conf->global->MAIN_MAX_DECIMALS_TOT; ?>;
|
||||
|
||||
var amount = num.toString();
|
||||
|
||||
// rounding for unit price
|
||||
var rounding = main_rounding_unit;
|
||||
var pos = amount.indexOf(dec);
|
||||
var decpart = '';
|
||||
if (pos >= 0) decpart = amount.substr(pos+1).replace('/0+$/i',''); // Supprime les 0 de fin de partie decimale
|
||||
var nbdec = decpart.length;
|
||||
if (nbdec > rounding) rounding = nbdec;
|
||||
// If rounding higher than max shown
|
||||
if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
|
||||
|
||||
if (thousand != ',' && thousand != '.') amount=amount.replace(',','.');
|
||||
amount=amount.replace(' ',''); // To avoid spaces
|
||||
amount=amount.replace(thousand,''); // Replace of thousand before replace of dec to avoid pb if thousand is .
|
||||
amount=amount.replace(dec,'.');
|
||||
|
||||
return parseFloat(amount).toFixed(rounding);
|
||||
}
|
||||
|
||||
<?php } ?>
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- END PHP TEMPLATE objectline_add.tpl.php -->
|
||||
455
htdocs/core/tpl/objectline_create.tpl.php
Normal file
455
htdocs/core/tpl/objectline_create.tpl.php
Normal file
@ -0,0 +1,455 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Need to have following variables defined:
|
||||
* $conf
|
||||
* $langs
|
||||
* $dateSelector
|
||||
* $this (invoice, order, ...)
|
||||
* $line defined
|
||||
*/
|
||||
|
||||
$usemargins=0;
|
||||
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1;
|
||||
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->
|
||||
|
||||
<tr class="liste_titre nodrag nodrop">
|
||||
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
|
||||
<div id="add"></div><span class="hideonsmartphone"><?php echo $langs->trans('AddNewLine'); ?></span><?php // echo $langs->trans("FreeZone"); ?>
|
||||
</td>
|
||||
<td align="right"><span id="title_vat"><?php echo $langs->trans('VAT'); ?></span></td>
|
||||
<td align="right"><span id="title_up_ht"><?php echo $langs->trans('PriceUHT'); ?></span></td>
|
||||
<td align="right"><?php echo $langs->trans('Qty'); ?></td>
|
||||
<td align="right"><?php echo $langs->trans('ReductionShort'); ?></td>
|
||||
<?php
|
||||
$colspan = 4;
|
||||
if (! empty($usemargins))
|
||||
{
|
||||
?>
|
||||
<td align="right">
|
||||
<?php
|
||||
if ($conf->global->MARGIN_TYPE == "1")
|
||||
echo $langs->trans('BuyingPrice');
|
||||
else
|
||||
echo $langs->trans('CostPrice');
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
if ($user->rights->margins->creer)
|
||||
{
|
||||
if(! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
{
|
||||
echo '<td align="right">'.$langs->trans('MarginRate').'</td>';
|
||||
}
|
||||
if(! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
{
|
||||
echo '<td align="right">'.$langs->trans('MarkRate').'</td>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<td colspan="<?php echo $colspan; ?>"> </td>
|
||||
</tr>
|
||||
|
||||
<tr <?php echo $bcnd[$var]; ?>>
|
||||
<?php
|
||||
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
|
||||
$coldisplay=2; }
|
||||
else {
|
||||
$coldisplay=0; }
|
||||
?>
|
||||
|
||||
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
jQuery('#idprod').change(function() {
|
||||
if (jQuery('#idprod').val() > 0) jQuery('#np_desc').focus();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
echo '<span>';
|
||||
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
|
||||
{
|
||||
echo '<input type="radio" name="prod_entry_mode" id="prod_entry_mode_free" value="free"'.(GETPOST('prod_entry_mode')=='free'?' checked="true"':'').'> ';
|
||||
}
|
||||
if (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) echo $langs->trans("FreeLineOfType").' ';
|
||||
else if (empty($conf->product->enabled) && ! empty($conf->service->enabled)) echo $langs->trans("FreeLineOfType").' '.$langs->trans("Service");
|
||||
else if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans("FreeLineOfType").' '.$langs->trans("Product");
|
||||
echo $form->select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1,1);
|
||||
echo '</span>';
|
||||
|
||||
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
|
||||
{
|
||||
echo '<br><span>';
|
||||
echo '<input type="radio" name="prod_entry_mode" id="prod_entry_mode_predef" value="predef"'.(GETPOST('prod_entry_mode')=='predef'?' checked="true"':'').'> ';
|
||||
|
||||
if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('RecordedProducts');
|
||||
else if (empty($conf->product->enabled) && ! empty($conf->service->enabled)) echo $langs->trans('RecordedServices');
|
||||
else echo $langs->trans('RecordedProductsAndServices');
|
||||
echo ' ';
|
||||
|
||||
$filtertype='';
|
||||
if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1';
|
||||
$form->select_produits('','idprod',$filtertype,$conf->product->limit_size,$buyer->price_level, 1, 2, '', 3, array(),$buyer->id);
|
||||
echo '</span>';
|
||||
}
|
||||
|
||||
if (is_object($hookmanager))
|
||||
{
|
||||
$parameters=array('fk_parent_line'=>GETPOST('fk_parent_line','int'));
|
||||
$reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action);
|
||||
}
|
||||
|
||||
//if ((! empty($conf->product->enabled) && ! empty($conf->service->enabled)) || (empty($conf->product->enabled) && empty($conf->service->enabled))) echo '<br>';
|
||||
echo '<br>';
|
||||
|
||||
// Editor wysiwyg
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$nbrows=ROWS_2;
|
||||
$enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
|
||||
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
|
||||
$doleditor=new DolEditor('dp_desc',GETPOST('dp_desc'),'',100,'dolibarr_details','',false,true,$enabled,$nbrows,'98%');
|
||||
$doleditor->Create();
|
||||
?>
|
||||
</td>
|
||||
|
||||
<td align="right"><?php
|
||||
if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" value="0">0';
|
||||
else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer);
|
||||
?>
|
||||
</td>
|
||||
<td align="right">
|
||||
<input type="text" size="5" name="price_ht" id="price_ht" class="flat" value="<?php echo (isset($_POST["price_ht"])?$_POST["price_ht"]:''); ?>">
|
||||
<input type="hidden" name="price_ht_predef" id="price_ht_predef">
|
||||
</td>
|
||||
<td align="right"><input type="text" size="2" name="qty" class="flat" value="<?php echo (isset($_POST["qty"])?$_POST["qty"]:1); ?>">
|
||||
</td>
|
||||
<td align="right" class="nowrap"><input type="text" size="1" class="flat" value="<?php echo (isset($_POST["remise_percent"])?$_POST["remise_percent"]:$buyer->remise_client); ?>" name="remise_percent"><span class="hideonsmartphone">%</span></td>
|
||||
<?php
|
||||
$colspan = 4;
|
||||
if (! empty($usemargins))
|
||||
{
|
||||
?>
|
||||
<td align="right">
|
||||
<!-- For predef product -->
|
||||
<?php if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { ?>
|
||||
<select id="fournprice_predef" name="fournprice_predef" class="flat" style="display: none;"></select>
|
||||
<?php } ?>
|
||||
<!-- For free product -->
|
||||
<input type="text" size="5" id="buying_price" name="buying_price" class="flat" value="<?php echo (isset($_POST["buying_price"])?$_POST["buying_price"]:''); ?>">
|
||||
</td>
|
||||
<?php
|
||||
$colspan++;
|
||||
$coldisplay++;
|
||||
|
||||
if ($user->rights->margins->creer)
|
||||
{
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
echo '<td align="right" class="nowrap"><input type="text" size="2" name="np_marginRate" value="'.(isset($_POST["np_marginRate"])?$_POST["np_marginRate"]:'').'"><span class="hideonsmartphone">%</span></td>';
|
||||
$colspan++;
|
||||
$coldisplay++;
|
||||
}
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
echo '<td align="right" class="nowrap"><input type="text" size="2" name="np_markRate" value="'.(isset($_POST["np_markRate"])?$_POST["np_markRate"]:'').'"><span class="hideonsmartphone">%</span></td>';
|
||||
$colspan++;
|
||||
$coldisplay++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
$colspan++;
|
||||
$coldisplay++;
|
||||
}
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
$colspan++;
|
||||
$coldisplay++;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<td align="center" valign="middle" colspan="<?php echo $colspan; ?>">
|
||||
<input type="submit" class="button" value="<?php echo $langs->trans('Add'); ?>" name="addline" id="addline">
|
||||
</td>
|
||||
<?php
|
||||
//Line extrafield
|
||||
if (!empty($extrafieldsline)) {
|
||||
if ($this->table_element_line=='commandedet') {
|
||||
$newline = new OrderLine($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='propaldet') {
|
||||
$newline = new PropaleLigne($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='facturedet') {
|
||||
$newline = new FactureLigne($this->db);
|
||||
}
|
||||
if (is_object($newline)) {
|
||||
print $newline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8));
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
if (! empty($conf->service->enabled) && $dateSelector)
|
||||
{
|
||||
if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10;
|
||||
else $colspan = 9;
|
||||
|
||||
if (! empty($usemargins))
|
||||
{
|
||||
$colspan++; // For the buying price
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
|
||||
}
|
||||
?>
|
||||
|
||||
<tr <?php echo $bcnd[$var]; ?>>
|
||||
<td colspan="<?php echo $colspan; ?>">
|
||||
<?php
|
||||
if (! empty($object->element) && $object->element == 'contrat')
|
||||
{
|
||||
print $langs->trans("DateStartPlanned").' ';
|
||||
$form->select_date('',"date_start",$usehm,$usehm,1,"addproduct");
|
||||
print ' '.$langs->trans("DateEndPlanned").' ';
|
||||
$form->select_date('',"date_end",$usehm,$usehm,1,"addproduct");
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
|
||||
echo $form->select_date('','date_start',empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,1,"addproduct");
|
||||
echo ' '.$langs->trans('to').' ';
|
||||
echo $form->select_date('','date_end',empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,1,"addproduct");
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
if (! empty($usemargins) && $user->rights->margins->creer)
|
||||
{
|
||||
?>
|
||||
|
||||
/* Some js test when we click on button "Add" */
|
||||
jQuery(document).ready(function() {
|
||||
<?php
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
|
||||
$('#addline').click(function (e) {
|
||||
return checkFreeLine(e, "np_marginRate");
|
||||
});
|
||||
$("input[name='np_marginRate']:first").blur(function(e) {
|
||||
return checkFreeLine(e, "np_marginRate");
|
||||
});
|
||||
<?php
|
||||
}
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) { ?>
|
||||
$('#addline').click(function (e) {
|
||||
return checkFreeLine(e, "np_markRate");
|
||||
});
|
||||
$("input[name='np_markRate']:first").blur(function(e) {
|
||||
return checkFreeLine(e, "np_markRate");
|
||||
});
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
});
|
||||
|
||||
/* TODO This does not work for number with thousand separator that is , */
|
||||
function checkFreeLine(e, npRate)
|
||||
{
|
||||
var buying_price = $("input[name='buying_price']:first");
|
||||
var remise = $("input[name='remise_percent']:first");
|
||||
|
||||
var rate = $("input[name='"+npRate+"']:first");
|
||||
if (rate.val() == '')
|
||||
return true;
|
||||
if (! $.isNumeric(rate.val().replace(',','.')))
|
||||
{
|
||||
alert('<?php echo dol_escape_js($langs->trans("rateMustBeNumeric")); ?>');
|
||||
e.stopPropagation();
|
||||
setTimeout(function () { rate.focus() }, 50);
|
||||
return false;
|
||||
}
|
||||
if (npRate == "np_markRate" && rate.val() >= 100)
|
||||
{
|
||||
alert('<?php echo dol_escape_js($langs->trans("markRateShouldBeLesserThan100")); ?>');
|
||||
e.stopPropagation();
|
||||
setTimeout(function () { rate.focus() }, 50);
|
||||
return false;
|
||||
}
|
||||
|
||||
var price = 0;
|
||||
remisejs=price2numjs(remise.val());
|
||||
|
||||
if (remisejs != 100)
|
||||
{
|
||||
bpjs=price2numjs(buying_price.val());
|
||||
ratejs=price2numjs(rate.val());
|
||||
|
||||
if (npRate == "marginRate")
|
||||
price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
|
||||
else if (npRate == "markRate")
|
||||
price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
|
||||
}
|
||||
$("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Function similar to price2num in PHP */
|
||||
function price2numjs(num)
|
||||
{
|
||||
<?php
|
||||
$dec=','; $thousand=' ';
|
||||
if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal");
|
||||
if ($langs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->transnoentitiesnoconv("SeparatorThousand");
|
||||
if ($thousand == 'None') $thousand='';
|
||||
print "var dec='".$dec."'; var thousand='".$thousand."';\n";
|
||||
?>
|
||||
|
||||
var main_max_dec_shown = <?php echo $conf->global->MAIN_MAX_DECIMALS_SHOWN; ?>;
|
||||
var main_rounding_unit = <?php echo $conf->global->MAIN_MAX_DECIMALS_UNIT; ?>;
|
||||
var main_rounding_tot = <?php echo $conf->global->MAIN_MAX_DECIMALS_TOT; ?>;
|
||||
|
||||
var amount = num.toString();
|
||||
|
||||
// rounding for unit price
|
||||
var rounding = main_rounding_unit;
|
||||
var pos = amount.indexOf(dec);
|
||||
var decpart = '';
|
||||
if (pos >= 0) decpart = amount.substr(pos+1).replace('/0+$/i',''); // Supprime les 0 de fin de partie decimale
|
||||
var nbdec = decpart.length;
|
||||
if (nbdec > rounding) rounding = nbdec;
|
||||
// If rounding higher than max shown
|
||||
if (rounding > main_max_dec_shown) rounding = main_max_dec_shown;
|
||||
|
||||
if (thousand != ',' && thousand != '.') amount=amount.replace(',','.');
|
||||
amount=amount.replace(' ',''); // To avoid spaces
|
||||
amount=amount.replace(thousand,''); // Replace of thousand before replace of dec to avoid pb if thousand is .
|
||||
amount=amount.replace(dec,'.');
|
||||
|
||||
return parseFloat(amount).toFixed(rounding);
|
||||
}
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
/* JQuery for product free or predefined select */
|
||||
jQuery(document).ready(function() {
|
||||
$("#prod_entry_mode_free").on( "click", function() {
|
||||
setforfree();
|
||||
});
|
||||
$("#select_type").change(function()
|
||||
{
|
||||
setforfree();
|
||||
if (jQuery('#select_type').val() >= 0) jQuery('#dp_desc').focus();
|
||||
});
|
||||
|
||||
$("#prod_entry_mode_predef").on( "click", function() {
|
||||
setforpredef();
|
||||
});
|
||||
$("#idprod").change(function()
|
||||
{
|
||||
setforpredef();
|
||||
|
||||
<?php if (! empty($usemargins) && $user->rights->margins->creer) { ?>
|
||||
|
||||
/* Code for margin */
|
||||
$("#fournprice_predef options").remove();
|
||||
$("#fournprice_predef").hide();
|
||||
$("#buying_price").val("").show();
|
||||
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', { 'idprod': $(this).val() }, function(data) {
|
||||
if (data && data.length > 0)
|
||||
{
|
||||
var options = '';
|
||||
var i = 0;
|
||||
$(data).each(function() {
|
||||
i++;
|
||||
options += '<option value="'+this.id+'" price="'+this.price+'"';
|
||||
if (i == 1) {
|
||||
options += ' selected';
|
||||
$("#buying_price").val(this.price);
|
||||
}
|
||||
options += '>'+this.label+'</option>';
|
||||
});
|
||||
options += '<option value=""><?php echo $langs->trans("InputPrice"); ?></option>';
|
||||
$("#buying_price").hide();
|
||||
$("#fournprice_predef").html(options).show();
|
||||
$("#fournprice_predef").change(function() {
|
||||
var selval = $(this).find('option:selected').attr("price");
|
||||
if (selval)
|
||||
$("#buying_price").val(selval).hide();
|
||||
else
|
||||
$('#buying_price').show();
|
||||
});
|
||||
}
|
||||
},
|
||||
'json');
|
||||
|
||||
if (jQuery('#idprod').val() > 0) jQuery('#dp_desc').focus();
|
||||
|
||||
<?php } ?>
|
||||
});
|
||||
});
|
||||
|
||||
/* Function to set fields from choice */
|
||||
function setforfree() {
|
||||
jQuery("#search_idprod").val('');
|
||||
jQuery("#idprod").val('');
|
||||
jQuery("#prod_entry_mode_free").attr('checked',true);
|
||||
jQuery("#prod_entry_mode_predef").attr('checked',false);
|
||||
jQuery("#price_ht").show();
|
||||
jQuery("#tva_tx").show();
|
||||
jQuery("#buying_price").val('').show();
|
||||
jQuery("#fournprice_predef").hide();
|
||||
jQuery("#title_vat").show();
|
||||
jQuery("#title_up_ht").show();
|
||||
}
|
||||
function setforpredef() {
|
||||
jQuery("#select_type").val(-1);
|
||||
jQuery("#prod_entry_mode_free").attr('checked',false);
|
||||
jQuery("#prod_entry_mode_predef").attr('checked',true);
|
||||
jQuery("#price_ht").hide();
|
||||
jQuery("#tva_tx").hide();
|
||||
jQuery("#buying_price").show();
|
||||
jQuery("#title_vat").hide();
|
||||
jQuery("#title_up_ht").hide();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<!-- END PHP TEMPLATE objectline_create.tpl.php -->
|
||||
@ -605,7 +605,8 @@ Notes=Notes
|
||||
AddNewLine=Add new line
|
||||
AddFile=Add file
|
||||
ListOfFiles=List of available files
|
||||
FreeZone=Free text
|
||||
FreeZone=Free entry
|
||||
FreeLineOfType=Free entry of type
|
||||
CloneMainAttributes=Clone object with its main attributes
|
||||
PDFMerge=PDF Merge
|
||||
Merge=Merge
|
||||
|
||||
Loading…
Reference in New Issue
Block a user