Skip to content

Commit

Permalink
New: Merge free product and predefined product area to enter new
Browse files Browse the repository at this point in the history
product (Supplier orders now use same template than customer
orders/proposal/invoices).
  • Loading branch information
eldy committed May 5, 2014
1 parent d224128 commit 131f133
Show file tree
Hide file tree
Showing 10 changed files with 266 additions and 155 deletions.
28 changes: 16 additions & 12 deletions htdocs/comm/propal.php
Expand Up @@ -572,18 +572,17 @@
}
}

if (empty($idprod) && GETPOST('type') < 0) {
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) {
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors');
$error ++;
}

if (empty($idprod) && $price_ht == '') // Unit price can be 0 but not ''. Also price can be negative for
// proposal.
if (GETPOST('prod_entry_mode') == 'free' && 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');
$error ++;
}
if (empty($idprod) && empty($product_desc)) {
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) {
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), 'errors');
$error ++;
}
Expand Down Expand Up @@ -754,15 +753,20 @@
unset($_POST ['np_marginRate']);
unset($_POST ['np_markRate']);
unset($_POST ['dp_desc']);

unset($_POST ['idprod']);
unset($_POST ['qty_predef']);
unset($_POST ['remise_percent_predef']);
unset($_POST ['fournprice_predef']);
unset($_POST ['buying_price_predef']);
unset($_POST ['np_marginRate_predef']);
unset($_POST ['np_markRate_predef']);
unset($_POST ['np_desc']);

unset($_POST['date_starthour']);
unset($_POST['date_startmin']);
unset($_POST['date_startsec']);
unset($_POST['date_startday']);
unset($_POST['date_startmonth']);
unset($_POST['date_startyear']);
unset($_POST['date_endhour']);
unset($_POST['date_endmin']);
unset($_POST['date_endsec']);
unset($_POST['date_endday']);
unset($_POST['date_endmonth']);
unset($_POST['date_endyear']);
} else {
$db->rollback();

Expand Down
27 changes: 16 additions & 11 deletions htdocs/commande/fiche.php
Expand Up @@ -513,11 +513,11 @@
setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors');
$error ++;
}
if (empty($idprod) && GETPOST('type') < 0) {
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors');
$error ++;
}
if (empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not ''
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not ''
{
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors');
$error ++;
Expand All @@ -526,7 +526,7 @@
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors');
$error ++;
}
if (empty($idprod) && empty($product_desc)) {
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors');
$error ++;
}
Expand Down Expand Up @@ -697,15 +697,20 @@
unset($_POST ['np_marginRate']);
unset($_POST ['np_markRate']);
unset($_POST ['dp_desc']);

unset($_POST ['idprod']);
unset($_POST ['qty_predef']);
unset($_POST ['remise_percent_predef']);
unset($_POST ['fournprice_predef']);
unset($_POST ['buying_price_predef']);
unset($_POST ['np_marginRate_predef']);
unset($_POST ['np_markRate_predef']);
unset($_POST ['np_desc']);

unset($_POST['date_starthour']);
unset($_POST['date_startmin']);
unset($_POST['date_startsec']);
unset($_POST['date_startday']);
unset($_POST['date_startmonth']);
unset($_POST['date_startyear']);
unset($_POST['date_endhour']);
unset($_POST['date_endmin']);
unset($_POST['date_endsec']);
unset($_POST['date_endday']);
unset($_POST['date_endmonth']);
unset($_POST['date_endyear']);
} else {
setEventMessage($object->error, 'errors');
}
Expand Down
27 changes: 16 additions & 11 deletions htdocs/compta/facture.php
Expand Up @@ -1077,11 +1077,11 @@
setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors');
$error ++;
}
if (empty($idprod) && GETPOST('type') < 0) {
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors');
$error ++;
}
if (empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not ''
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not ''
{
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors');
$error ++;
Expand All @@ -1090,7 +1090,7 @@
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors');
$error ++;
}
if (empty($idprod) && empty($product_desc)) {
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors');
$error ++;
}
Expand Down Expand Up @@ -1269,15 +1269,20 @@
unset($_POST['np_marginRate']);
unset($_POST['np_markRate']);
unset($_POST['dp_desc']);

unset($_POST['idprod']);
unset($_POST['qty_predef']);
unset($_POST['remise_percent_predef']);
unset($_POST['fournprice_predef']);
unset($_POST['buying_price_predef']);
unset($_POST['np_marginRate_predef']);
unset($_POST['np_markRate_predef']);
unset($_POST['np_desc']);

unset($_POST['date_starthour']);
unset($_POST['date_startmin']);
unset($_POST['date_startsec']);
unset($_POST['date_startday']);
unset($_POST['date_startmonth']);
unset($_POST['date_startyear']);
unset($_POST['date_endhour']);
unset($_POST['date_endmin']);
unset($_POST['date_endsec']);
unset($_POST['date_endday']);
unset($_POST['date_endmonth']);
unset($_POST['date_endyear']);
} else {
setEventMessage($object->error, 'errors');
}
Expand Down
25 changes: 16 additions & 9 deletions htdocs/contrat/fiche.php
Expand Up @@ -378,7 +378,7 @@
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")),'errors');
$error++;
}
if ((GETPOST('price_ht') == '' || ! GETPOST('dp_desc')) && ! GETPOST('idprod'))
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc))
{
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")),'errors');
$error++;
Expand Down Expand Up @@ -526,16 +526,23 @@
unset($_POST['product_desc']);
unset($_POST['fournprice']);
unset($_POST['buying_price']);
unset($_POST ['np_marginRate']);
unset($_POST ['np_markRate']);
unset($_POST['dp_desc']);

unset($_POST['idprod']);
unset($_POST['qty_predef']);
unset($_POST['remise_percent_predef']);
unset($_POST['fournprice_predef']);
unset($_POST['buying_price_predef']);
unset($_POST['np_marginRate_predef']);
unset($_POST['np_markRate_predef']);
unset($_POST['np_desc']);

unset($_POST['date_starthour']);
unset($_POST['date_startmin']);
unset($_POST['date_startsec']);
unset($_POST['date_startday']);
unset($_POST['date_startmonth']);
unset($_POST['date_startyear']);
unset($_POST['date_endhour']);
unset($_POST['date_endmin']);
unset($_POST['date_endsec']);
unset($_POST['date_endday']);
unset($_POST['date_endmonth']);
unset($_POST['date_endyear']);
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/class/html.form.class.php
Expand Up @@ -1697,9 +1697,10 @@ private function constructProductListOption(&$objp, &$opt, &$optJson, $price_lev
* @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service)
* @param string $filtre For a SQL filter
* @param array $ajaxoptions Options for ajax_autocompleter
* @param int $hidelabel Hide label (0=no, 1=yes)
* @return void
*/
function select_produits_fournisseurs($socid, $selected='', $htmlname='productid', $filtertype='', $filtre='', $ajaxoptions=array())
function select_produits_fournisseurs($socid, $selected='', $htmlname='productid', $filtertype='', $filtre='', $ajaxoptions=array(), $hidelabel=0)
{
global $langs,$conf;
global $price_level, $status, $finished;
Expand All @@ -1709,8 +1710,7 @@ function select_produits_fournisseurs($socid, $selected='', $htmlname='productid
// mode=2 means suppliers products
$urloption=($socid > 0?'socid='.$socid.'&':'').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished;
print ajax_autocompleter('', $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
print $langs->trans("RefOrLabel").' : <input type="text" size="16" name="search_'.$htmlname.'" id="search_'.$htmlname.'">';
print '<br>';
print ($hidelabel?'':$langs->trans("RefOrLabel").' : ').'<input type="text" size="16" name="search_'.$htmlname.'" id="search_'.$htmlname.'">';
}
else
{
Expand Down
7 changes: 5 additions & 2 deletions htdocs/core/lib/ajax.lib.php
Expand Up @@ -129,9 +129,12 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
if (ui.item.disabled) {
$("#" + options.option_disabled).attr("disabled", "disabled");
if (options.error) {
$.jnotify(options.error, "error", true);
$.jnotify(options.error, "error", true); // Output with jnotify the error message
}
} else {
if (options.warning) {
$.jnotify(options.warning, "warning", false); // Output with jnotify the warning message
}
} else {
$("#" + options.option_disabled).removeAttr("disabled");
}
}
Expand Down

0 comments on commit 131f133

Please sign in to comment.