NEW add state origin for product
usefull for food, fruits or vegetables or regional product soon in other PR i will push filter by state or country in product list
This commit is contained in:
parent
cde58c6908
commit
de31920f28
@ -44,6 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
||||
@ -290,7 +291,8 @@ if (empty($reshook))
|
||||
$object->note_private = dol_htmlcleanlastbr(GETPOST('note_private', 'none'));
|
||||
$object->note = $object->note_private; // deprecated
|
||||
$object->customcode = GETPOST('customcode', 'alphanohtml');
|
||||
$object->country_id = GETPOST('country_id', 'int');
|
||||
$object->country_id = GETPOST('country_id', 'int');
|
||||
$object->state_id = GETPOST('state_id', 'int');
|
||||
$object->duration_value = $duration_value;
|
||||
$object->duration_unit = $duration_unit;
|
||||
$object->fk_default_warehouse = GETPOST('fk_default_warehouse');
|
||||
@ -395,7 +397,8 @@ if (empty($reshook))
|
||||
$object->note = $object->note_private;
|
||||
}
|
||||
$object->customcode = GETPOST('customcode', 'alpha');
|
||||
$object->country_id = GETPOST('country_id', 'int');
|
||||
$object->country_id = GETPOST('country_id', 'int');
|
||||
$object->state_id = GETPOST('state_id', 'int');
|
||||
$object->status = GETPOST('statut', 'int');
|
||||
$object->status_buy = GETPOST('statut_buy', 'int');
|
||||
$object->status_batch = GETPOST('status_batch', 'aZ09');
|
||||
@ -865,7 +868,8 @@ llxHeader('', $title, $helpurl);
|
||||
|
||||
$form = new Form($db);
|
||||
$formfile = new FormFile($db);
|
||||
$formproduct = new FormProduct($db);
|
||||
$formproduct = new FormProduct($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
|
||||
|
||||
// Load object modBarCodeProduct
|
||||
@ -899,14 +903,25 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
}
|
||||
$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
|
||||
$objcanvas->display_canvas($action); // Show template
|
||||
} else {
|
||||
} else {
|
||||
|
||||
// -----------------------------------------
|
||||
// When used in standard mode
|
||||
// -----------------------------------------
|
||||
if ($action == 'create' && $usercancreate)
|
||||
{
|
||||
|
||||
//WYSIWYG Editor
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
|
||||
print '<script type="text/javascript">';
|
||||
print '$(document).ready(function () {
|
||||
$("#selectcountry_id").change(function() {
|
||||
document.formprod.action.value="create";
|
||||
document.formprod.submit();
|
||||
});
|
||||
});';
|
||||
print '</script>'."\n";
|
||||
|
||||
// Load object modCodeProduct
|
||||
$module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard');
|
||||
@ -919,10 +934,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
{
|
||||
$modCodeProduct = new $module();
|
||||
}
|
||||
|
||||
|
||||
dol_set_focus('input[name="ref"]');
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="formprod">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="type" value="'.$type.'">'."\n";
|
||||
@ -941,6 +956,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
}
|
||||
$linkback = "";
|
||||
print load_fiche_titre($title, $linkback, $picto);
|
||||
|
||||
// We set country_id, country_code and country for the selected country
|
||||
$object->country_id = GETPOST('country_id') ?GETPOST('country_id') : null;
|
||||
if ($object->country_id)
|
||||
{
|
||||
$tmparray = getCountry($object->country_id, 'all');
|
||||
$object->country_code = $tmparray['code'];
|
||||
$object->country = $tmparray['label'];
|
||||
}
|
||||
|
||||
dol_fiche_head('');
|
||||
|
||||
@ -1114,14 +1138,31 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
// Custom code
|
||||
if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO) && empty($type))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.GETPOST('customcode').'"></td>';
|
||||
if ($conf->browser->layout == 'phone') print '</tr><tr>';
|
||||
print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.GETPOST('customcode').'"></td></tr>';
|
||||
|
||||
// Origin country
|
||||
print '<td>'.$langs->trans("CountryOrigin").'</td>';
|
||||
print '<td>';
|
||||
print $form->select_country(GETPOST('country_id', 'int'), 'country_id');
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
print '</td></tr>';
|
||||
print img_picto('', 'globe-americas', 'class="paddingrightonly"');
|
||||
print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id') : $object->country_id), 'country_id', '', 0, 'minwidth300 widthcentpercentminusx');
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
print '</td>';
|
||||
|
||||
// State
|
||||
if (empty($conf->global->PRODUCT_DISABLE_STATE))
|
||||
{
|
||||
if ($conf->browser->layout == 'phone') print '</tr><tr>';
|
||||
if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
|
||||
{
|
||||
print '<td>'.$form->editfieldkey('Region-StateOrigine', 'state_id', '', $object, 0).'</td><td colspan="3">';
|
||||
} else {
|
||||
print '<td>'.$form->editfieldkey('StateOrigin', 'state_id', '', $object, 0).'</td><td colspan="3">';
|
||||
}
|
||||
|
||||
print $formcompany->select_state($object->state_id, $object->country_code);
|
||||
print '</tr>';
|
||||
}
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
@ -1324,6 +1365,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
|
||||
print '</form>';
|
||||
} elseif ($object->id > 0) {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Product card
|
||||
*/
|
||||
@ -1332,13 +1376,32 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
{
|
||||
//WYSIWYG Editor
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
|
||||
|
||||
print '<script type="text/javascript">';
|
||||
print '$(document).ready(function () {
|
||||
$("#selectcountry_id").change(function() {
|
||||
document.formprod.action.value="edit";
|
||||
document.formprod.submit();
|
||||
});
|
||||
});';
|
||||
print '</script>'."\n";
|
||||
|
||||
// We set country_id, country_code and country for the selected country
|
||||
$object->country_id = GETPOST('country_id') ? GETPOST('country_id') : $object->country_id;
|
||||
if ($object->country_id)
|
||||
{
|
||||
$tmparray = getCountry($object->country_id, 'all');
|
||||
$object->country_code = $tmparray['code'];
|
||||
$object->country = $tmparray['label'];
|
||||
}
|
||||
|
||||
|
||||
$type = $langs->trans('Product');
|
||||
if ($object->isService()) $type = $langs->trans('Service');
|
||||
//print load_fiche_titre($langs->trans('Modify').' '.$type.' : '.(is_object($object->oldcopy)?$object->oldcopy->ref:$object->ref), "");
|
||||
|
||||
// Main official, simple, and not duplicated code
|
||||
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST">'."\n";
|
||||
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST" name="formprod">'."\n";
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
@ -1348,6 +1411,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
$titre = $langs->trans("CardProduct".$object->type);
|
||||
$picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
|
||||
dol_fiche_head($head, 'card', $titre, 0, $picto);
|
||||
|
||||
|
||||
print '<table class="border allwidth">';
|
||||
|
||||
@ -1529,13 +1593,30 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
// Custom code
|
||||
if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.$object->customcode.'"></td>';
|
||||
// Origin country
|
||||
print '<td>'.$langs->trans("CountryOrigin").'</td><td>';
|
||||
print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.$object->customcode.'"></td></tr>';
|
||||
// Origin country
|
||||
print '<td>'.$langs->trans("CountryOrigin").'</td>';
|
||||
print '<td>';
|
||||
print img_picto('', 'globe-americas', 'class="paddingrightonly"');
|
||||
print $form->select_country($object->country_id, 'country_id', '', 0, 'minwidth100 maxwidthonsmartphone');
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
print '</td>';
|
||||
// State
|
||||
if (empty($conf->global->PRODUCT_DISABLE_STATE))
|
||||
{
|
||||
if ($conf->browser->layout == 'phone') print '</tr><tr>';
|
||||
if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
|
||||
{
|
||||
print '<td>'.$form->editfieldkey('Region-StateOrigine', 'state_id', '', $object, 0).'</td><td colspan="3">';
|
||||
} else {
|
||||
print '<td>'.$form->editfieldkey('StateOrigin', 'state_id', '', $object, 0).'</td><td colspan="3">';
|
||||
}
|
||||
|
||||
print $formcompany->select_state($object->state_id, $object->country_code);
|
||||
print '</td>';
|
||||
}
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters = array('colspan' => ' colspan="3"', 'cols' => 3);
|
||||
@ -2031,7 +2112,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
print '<tr><td>'.$langs->trans("CustomCode").'</td><td colspan="2">'.$object->customcode.'</td>';
|
||||
|
||||
// Origin country code
|
||||
print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td colspan="2">'.getCountry($object->country_id, 0, $db).'</td>';
|
||||
print '<tr><td>'.$langs->trans("Origin").'</td><td colspan="2">'.getCountry($object->country_id, 0, $db);
|
||||
if (!empty($object->state_id)) print ' - '.getState($object->state_id, 0, $db);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
|
||||
Loading…
Reference in New Issue
Block a user