Merge remote branch 'upstream/develop' into printgcp

Conflicts:
	htdocs/core/actions_printing.inc.php
This commit is contained in:
frederic34 2015-11-02 11:43:34 +01:00
commit 9149032a03
58 changed files with 916 additions and 388 deletions

View File

@ -57,7 +57,7 @@ JsTimezoneDetect 1.0.4 MIT License Yes
Raven.js 1.1.19 MIT License Yes Used for client-side error logging with Sentry logger
For licenses compatibility informations:
http://www.fsf.org/licensing/licenses/index_html
http://www.gnu.org/licenses/licenses.en.html
Copyright

View File

@ -1,5 +1,7 @@
# DOLIBARR ERP & CRM
![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg) ![Downloads per day](https://img.shields.io/sourceforge/dd/dolibarr.svg)
Dolibarr ERP & CRM is a modern software to manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda, ...).
It's an Open Source software (wrote in PHP language) designed for small and medium companies, foundation and freelances.

View File

@ -92,7 +92,6 @@ if (! function_exists("ldap_connect"))
setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
}
dol_fiche_head($head, 'ldap', $langs->trans("LDAPSetup"));
$var=true;
$form=new Form($db);
@ -101,6 +100,8 @@ $form=new Form($db);
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
dol_fiche_head($head, 'ldap', $langs->trans("LDAPSetup"));
print '<table class="noborder" width="100%">';
// Liste de synchro actives
@ -135,7 +136,7 @@ if (! empty($conf->societe->enabled))
print '</td><td>'.$langs->trans("LDAPDnContactActiveExample").'</td></tr>';
}
// Synchro adherentt active
// Synchro member active
if (! empty($conf->adherent->enabled))
{
$var=!$var;
@ -143,6 +144,7 @@ if (! empty($conf->adherent->enabled))
$arraylist=array();
$arraylist['0']=$langs->trans("No");
$arraylist['1']=$langs->trans("DolibarrToLDAP");
$arraylist['ldap2dolibarr']=$langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')';
print $form->selectarray('activemembers',$arraylist,$conf->global->LDAP_MEMBER_ACTIVE);
print '</td><td>'.$langs->trans("LDAPDnMemberActiveExample").'</td></tr>';
}
@ -239,12 +241,12 @@ print '</td><td>secret</td></tr>';
print '</table>';
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
print '</form>';
print '</div>';
print '<br>';

View File

@ -92,6 +92,8 @@ if ($action == 'setvalue' && $user->admin)
* View
*/
$form=new Form($db);
llxHeader('',$langs->trans("LDAPSetup"),'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP');
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
@ -114,8 +116,6 @@ print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$form=new Form($db);
print '<table class="noborder" width="100%">';
$var=true;
@ -263,16 +263,16 @@ print '</td><td>&nbsp;</td>';
print '<td align="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_COUNTRY"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_COUNTRY?' checked':'')."></td>";
print '</tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print '</table>';
print info_admin($langs->trans("LDAPDescValues"));
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
print '</form>';
print '</div>';
print info_admin($langs->trans("LDAPDescValues"));
/*
* Test de la connexion

View File

@ -177,16 +177,16 @@ print '</td><td>'.$langs->trans("LDAPFieldGroupMembersExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_GROUPMEMBERS"'.(($conf->global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS==$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)?' checked':'')."></td>";
print '</tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print '</table>';
print info_admin($langs->trans("LDAPDescValues"));
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
print '</form>';
print '</div>';
print info_admin($langs->trans("LDAPDescValues"));
/*
* Test de la connexion

View File

@ -53,6 +53,7 @@ if ($action == 'setvalue' && $user->admin)
if (! dolibarr_set_const($db, 'LDAP_MEMBER_DN',GETPOST("user"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS',GETPOST("objectclass"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FILTER',GETPOST("filterconnection"),'chaine',0,'',$conf->entity)) $error++;
// Members
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FULLNAME',GETPOST("fieldfullname"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN',GETPOST("fieldlogin"),'chaine',0,'',$conf->entity)) $error++;
@ -107,6 +108,8 @@ if ($action == 'setvalue' && $user->admin)
* View
*/
$form=new Form($db);
llxHeader('',$langs->trans("LDAPSetup"),'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP');
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
@ -120,6 +123,9 @@ if (! function_exists("ldap_connect"))
setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
}
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
dol_fiche_head($head, 'members', $langs->trans("LDAPSetup"));
@ -127,11 +133,6 @@ print $langs->trans("LDAPDescMembers").'<br>';
print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$form=new Form($db);
print '<table class="noborder" width="100%">';
$var=true;
@ -156,6 +157,14 @@ print '</td><td>'.$langs->trans("LDAPMemberObjectClassListExample").'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
// Filter, used to filter search
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFilterConnection").'</td><td>';
print '<input size="48" type="text" name="filterconnection" value="'.$conf->global->LDAP_MEMBER_FILTER.'">';
print '</td><td>'.$langs->trans("LDAPFilterConnectionExample").'</td>';
print '<td></td>';
print '</tr>';
print '</table>';
print '<br>';
print '<table class="noborder" width="100%">';
@ -377,15 +386,16 @@ print '</td><td>&nbsp;</td>';
print '<td align="right">&nbsp;</td>';
print '</tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print '</table>';
print info_admin($langs->trans("LDAPDescValues"));
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
print '</form>';
print '</div>';
print info_admin($langs->trans("LDAPDescValues"));
/*
@ -454,6 +464,7 @@ if (function_exists("ldap_connect"))
}
$db->close();
llxFooter();
$db->close();

View File

@ -63,7 +63,7 @@ if ($action == 'setvalue' && $user->admin)
if (! dolibarr_set_const($db, 'LDAP_FIELD_MAIL',GETPOST("fieldmail"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_PHONE',GETPOST("fieldphone"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_MOBILE',GETPOST("fieldmobile"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_FAX',GETPOST("fieldfax"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION',GETPOST("fielddescription"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_SID',GETPOST("fieldsid"),'chaine',0,'',$conf->entity)) $error++;
@ -93,6 +93,8 @@ if ($action == 'setvalue' && $user->admin)
* Visu
*/
$form=new Form($db);
llxHeader('',$langs->trans("LDAPSetup"),'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP');
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
@ -106,18 +108,19 @@ if (! function_exists("ldap_connect"))
setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors');
}
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
dol_fiche_head($head, 'users', $langs->trans("LDAPSetup"));
print $langs->trans("LDAPDescUsers").'<br>';
print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$form=new Form($db);
print '<table class="noborder" width="100%">';
$var=true;
@ -141,8 +144,7 @@ print '</td><td>'.$langs->trans("LDAPUserObjectClassListExample").'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
// Filtre
//Utilise pour filtrer la recherche
// Filter, used to filter search
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFilterConnection").'</td><td>';
print '<input size="48" type="text" name="filterconnection" value="'.$conf->global->LDAP_FILTER_CONNECTION.'">';
@ -281,16 +283,16 @@ print '</td><td>'.$langs->trans("LDAPFieldSidExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_SID"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_SID)?' checked':'')."></td>";
print '</tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print '</table>';
print '</form>';
print '</div>';
print info_admin($langs->trans("LDAPDescValues"));
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
print '</form>';
/*
* Test de la connexion
@ -392,7 +394,7 @@ if (function_exists("ldap_connect"))
$conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
$conf->global->LDAP_FIELD_PHONE,
$conf->global->LDAP_FIELD_FAX,
$conf->global->LDAP_FIELD_SKYPE,
$conf->global->LDAP_FIELD_SKYPE,
$conf->global->LDAP_FIELD_MOBILE,
$conf->global->LDAP_FIELD_MAIL,
$conf->global->LDAP_FIELD_TITLE,

View File

@ -66,7 +66,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
* View
*/
$textobject=$langs->transnoentitiesnoconv("OrderLines");
$textobject=$langs->transnoentitiesnoconv("Orders");
llxHeader('',$langs->trans("OrdersSetup"));

View File

@ -92,7 +92,7 @@ if ($action == 'initbarcodeproducts')
if (! is_object($modBarCodeProduct))
{
$error++;
setEventMessage($langs->trans("NoBarcodeNumberingTemplateDefined"),'errors');
setEventMessages($langs->trans("NoBarcodeNumberingTemplateDefined"), null, 'errors');
}
if (! $error)
@ -109,7 +109,7 @@ if ($action == 'initbarcodeproducts')
$resql=$db->query($sql);
if ($resql)
{
setEventMessage($langs->trans("AllBarcodeReset"),'mesgs');
setEventMessages($langs->trans("AllBarcodeReset"), null, 'mesgs');
}
else
{
@ -160,7 +160,7 @@ if ($action == 'initbarcodeproducts')
if (! $error)
{
setEventMessage($langs->trans("RecordsModified",$nbok),'mesgs');
setEventMessages($langs->trans("RecordsModified",$nbok), null, 'mesgs');
}
}

View File

@ -68,7 +68,7 @@ if (GETPOST('submitproduct') && GETPOST('submitproduct'))
if (empty($forbarcode) || empty($fk_barcode_type))
{
setEventMessage($langs->trans("DefinitionOfBarCodeForProductNotComplete",$producttmp->getNomUrl()), 'warnings');
setEventMessages($langs->trans("DefinitionOfBarCodeForProductNotComplete",$producttmp->getNomUrl()), null, 'warnings');
}
}
}
@ -85,7 +85,7 @@ if (GETPOST('submitthirdparty') && GETPOST('submitthirdparty'))
if (empty($forbarcode) || empty($fk_barcode_type))
{
setEventMessage($langs->trans("DefinitionOfBarCodeForProductNotComplete",$thirdpartytmp->getNomUrl()), 'warnings');
setEventMessages($langs->trans("DefinitionOfBarCodeForProductNotComplete",$thirdpartytmp->getNomUrl()), null, 'warnings');
}
}
}
@ -114,7 +114,7 @@ if ($action == 'builddoc')
if ($result <= 0)
{
$error++;
setEventMessage('Failed to get bar code type information '.$stdobject->error, 'errors');
setEventMessages('Failed to get bar code type information '.$stdobject->error, $stdobject->errors, 'errors');
}
}
@ -158,13 +158,13 @@ if ($action == 'builddoc')
if ($result <= 0 || ! dol_is_file($barcodeimage))
{
$error++;
setEventMessage('Failed to generate image file of barcode for code='.$code.' encoding='.$encoding.' file='.basename($barcodeimage), 'errors');
setEventMessages('Failed to generate image file of barcode for code='.$code.' encoding='.$encoding.' file='.basename($barcodeimage), null, 'errors');
}
}
else
{
$error++;
setEventMessage("Error, encoding ".$encoding." is not supported by encoder ".$generator.'. You must choose another barcode type or install a barcode generation engine that support '.$encoding, 'errors');
setEventMessages("Error, encoding ".$encoding." is not supported by encoder ".$generator.'. You must choose another barcode type or install a barcode generation engine that support '.$encoding, null, 'errors');
}
} else {
$template = 'tcpdflabel';

View File

@ -42,12 +42,12 @@ if ($action == 'setvalue')
if (! $error)
{
$db->commit();
setEventMessage($langs->trans("SetupSaved"));
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
setEventMessage($langs->trans("Error"), 'errors');
setEventMessages($langs->trans("Error"), null, 'errors');
}
}

View File

@ -78,12 +78,12 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update')
if (! $title) {
$error++;
setEventMessage($langs->transnoentities("ErrorFieldRequired",$langs->trans("BookmarkTitle")), 'errors');
setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("BookmarkTitle")), null, 'errors');
}
if (! $url) {
$error++;
setEventMessage($langs->transnoentities("ErrorFieldRequired",$langs->trans("UrlOrLink")), 'errors');
setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("UrlOrLink")), null, 'errors');
}
if (! $error)
@ -104,11 +104,11 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update')
if ($bookmark->errno == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
setEventMessage($langs->transnoentities("WarningBookmarkAlreadyExists"), 'warnings');
setEventMessages($langs->transnoentities("WarningBookmarkAlreadyExists"), null, 'warnings');
}
else
{
setEventMessage($bookmark->error, 'errors');
setEventMessages($bookmark->error, $bookmark->errors, 'errors');
}
$action = $invertedaction;
}

View File

@ -60,7 +60,7 @@ if ($_GET["action"] == 'delete')
}
else
{
setEventMessage($bookmark->error, 'errors');
setEventMessages($bookmark->error, $bookmark->errors, 'errors');
}
}

View File

@ -66,12 +66,12 @@ if (GETPOST('action','alpha') == 'set')
if (! $error)
{
$db->commit();
setEventMessage($langs->trans("SetupSaved"));
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
setEventMessage($langs->trans("Error"), 'errors');
setEventMessages($langs->trans("Error"), null, 'errors');
}
}

View File

@ -155,7 +155,7 @@ if ($action == 'add' && $user->rights->categorie->creer)
}
else
{
setEventMessage($object->error,'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
}

View File

@ -151,8 +151,7 @@ if (empty($reshook))
$result=$cat->del_type($object,$elementtype);
if ($result < 0)
{
setEventMessage($cat->error,'errors');
setEventMessage($cat->errors,'errors');
setEventMessages($cat->error, $cat->errors, 'errors');
}
}
@ -199,17 +198,17 @@ if (empty($reshook))
$result=$cat->add_type($object,$elementtype);
if ($result >= 0)
{
setEventMessage($langs->trans("WasAddedSuccessfully",$cat->label));
setEventMessages($langs->trans("WasAddedSuccessfully",$cat->label), null, 'mesgs');
}
else
{
if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
setEventMessage($langs->trans("ObjectAlreadyLinkedToCategory"),'warnings');
setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings');
}
else
{
setEventMessages( $cat->error, $cat->errors, 'errors' );
setEventMessages($cat->error, $cat->errors, 'errors');
}
}
}

View File

@ -140,7 +140,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
{
if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
{
setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors');
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
}
else
{
@ -151,7 +151,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result);
exit();
} else {
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
$action = '';
}
}
@ -347,7 +347,7 @@ if ($action == 'add')
$db->rollback();
$langs->load("errors");
$error=$langs->trans($object->error);
setEventMessage($error,'errors');
setEventMessages($error, null, 'errors');
$action = 'create'; $donotclearsession=1;
}
}
@ -551,8 +551,7 @@ if ($action == 'mupdate')
$result=$object->update($user);
if ($result < 0)
{
setEventMessage($object->error,'errors');
setEventMessage($object->errors,'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
if (! empty($backtopage))

View File

@ -114,7 +114,7 @@ if (empty($reshook))
{
if (1 == 0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
{
setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors');
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
}
else
{
@ -123,8 +123,10 @@ if (empty($reshook))
if ($result > 0) {
header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result);
exit();
} else {
setEventMessage($object->error, 'errors');
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
$action = '';
}
}
@ -140,7 +142,7 @@ if (empty($reshook))
exit();
} else {
$langs->load("errors");
setEventMessage($langs->trans($object->error), 'errors');
setEventMessages($langs->trans($object->error), null, 'errors');
}
}
@ -198,8 +200,8 @@ if (empty($reshook))
}
} else {
$langs->load("errors");
if (count($object->errors) > 0) setEventMessage($object->errors, 'errors');
else setEventMessage($langs->trans($object->error), 'errors');
if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors');
else setEventMessages($langs->trans($object->error), null, 'errors');
}
}
@ -249,7 +251,7 @@ if (empty($reshook))
$id = $object->create_from($user);
} else {
setEventMessage($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_askpricesupplier')), 'errors');
setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_askpricesupplier')), null, 'errors');
}
} else {
$object->ref = GETPOST('ref');
@ -484,7 +486,7 @@ if (empty($reshook))
if ($object->id > 0) {
$result = $object->insert_discount($_POST["remise_id"]);
if ($result < 0) {
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
@ -674,7 +676,7 @@ if (empty($reshook))
if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) {
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
setEventMessage($mesg, 'errors');
setEventMessages($mesg, null, 'errors');
} else {
// Insert line
$ref_fourn = GETPOST('fourn_ref');
@ -716,7 +718,7 @@ if (empty($reshook))
} else {
$db->rollback();
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
@ -774,7 +776,7 @@ if (empty($reshook))
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) {
setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors');
setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
$error ++;
}
} else {
@ -823,7 +825,7 @@ if (empty($reshook))
} else {
$db->rollback();
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
@ -865,9 +867,9 @@ if (empty($reshook))
$file = $upload_dir . '/' . GETPOST('file');
$ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret)
setEventMessage($langs->trans("FileWasRemoved", GETPOST('file')));
setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
else
setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors');
setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
}
}
@ -1325,7 +1327,7 @@ if ($action == 'create')
$numref = $object->getNextNumRef($soc);
if (empty($numref)) {
$error ++;
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
} else {
$numref = $object->ref;

View File

@ -2649,11 +2649,18 @@ class AskPriceSupplierLine extends CommonObject
if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente
if ($this->pa_ht == 0) {
if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
}
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{
return $result;
}
else
{
$this->pa_ht = $result;
}
}
// Check parameters
if ($this->product_type < 0) return -1;
@ -2817,10 +2824,17 @@ class AskPriceSupplierLine extends CommonObject
if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente
if ($this->pa_ht == 0) {
if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{
return $result;
}
else
{
$this->pa_ht = $result;
}
}
$this->db->begin();

View File

@ -496,17 +496,7 @@ class Propal extends CommonObject
$this->line->date_start=$date_start;
$this->line->date_end=$date_end;
// infos marge
if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) {
// by external module, take lowest buying price
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
$productFournisseur = new ProductFournisseur($this->db);
$productFournisseur->find_min_price_product_fournisseur($fk_product);
$this->line->fk_fournprice = $productFournisseur->product_fourn_price_id;
} else {
$this->line->fk_fournprice = $fk_fournprice;
}
$this->line->fk_fournprice = $fk_fournprice;
$this->line->pa_ht = $pa_ht;
// Mise en option de la ligne
@ -660,16 +650,7 @@ class Propal extends CommonObject
$this->line->skip_update_total = $skip_update_total;
$this->line->fk_unit = $fk_unit;
// infos marge
if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) {
// by external module, take lowest buying price
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
$productFournisseur = new ProductFournisseur($this->db);
$productFournisseur->find_min_price_product_fournisseur($fk_product);
$this->line->fk_fournprice = $productFournisseur->product_fourn_price_id;
} else {
$this->line->fk_fournprice = $fk_fournprice;
}
$this->line->fk_fournprice = $fk_fournprice;
$this->line->pa_ht = $pa_ht;
$this->line->date_start=$date_start;
@ -3124,11 +3105,18 @@ class PropaleLigne extends CommonObjectLine
if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente
if ($this->pa_ht == 0) {
if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
}
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{
return $result;
}
else
{
$this->pa_ht = $result;
}
}
// Check parameters
if ($this->product_type < 0) return -1;
@ -3296,10 +3284,17 @@ class PropaleLigne extends CommonObjectLine
if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente
if ($this->pa_ht == 0) {
if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{
return $result;
}
else
{
$this->pa_ht = $result;
}
}
$this->db->begin();

View File

@ -1281,16 +1281,7 @@ class Commande extends CommonOrder
$this->line->date_start=$date_start;
$this->line->date_end=$date_end;
// infos marge
if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) {
// by external module, take lowest buying price
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
$productFournisseur = new ProductFournisseur($this->db);
$productFournisseur->find_min_price_product_fournisseur($fk_product);
$this->line->fk_fournprice = $productFournisseur->product_fourn_price_id;
} else {
$this->line->fk_fournprice = $fk_fournprice;
}
$this->line->fk_fournprice = $fk_fournprice;
$this->line->pa_ht = $pa_ht;
// TODO Ne plus utiliser
@ -2509,16 +2500,7 @@ class Commande extends CommonOrder
$this->line->skip_update_total=$skip_update_total;
$this->line->fk_unit=$fk_unit;
// infos marge
if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) {
//by external module, take lowest buying price
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
$productFournisseur = new ProductFournisseur($this->db);
$productFournisseur->find_min_price_product_fournisseur($fk_product);
$this->line->fk_fournprice = $productFournisseur->product_fourn_price_id;
} else {
$this->line->fk_fournprice = $fk_fournprice;
}
$this->line->fk_fournprice = $fk_fournprice;
$this->line->pa_ht = $pa_ht;
// TODO deprecated
@ -3550,10 +3532,17 @@ class OrderLine extends CommonOrderLine
if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente
if ($this->pa_ht == 0) {
if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{
return $result;
}
else
{
$this->pa_ht = $result;
}
}
// Check parameters
@ -3677,10 +3666,17 @@ class OrderLine extends CommonOrderLine
if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseigné et utilisé pour calcul des marges alors prix achat = prix vente
if ($this->pa_ht == 0) {
if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{
return $result;
}
else
{
$this->pa_ht = $result;
}
}
$this->db->begin();

View File

@ -2361,16 +2361,7 @@ class Facture extends CommonInvoice
$this->line->situation_percent = $situation_percent;
$this->line->fk_unit = $fk_unit;
// infos marge
if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) {
// POS or external module, take lowest buying price
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
$productFournisseur = new ProductFournisseur($this->db);
$productFournisseur->find_min_price_product_fournisseur($fk_product);
$this->line->fk_fournprice = $productFournisseur->product_fourn_price_id;
} else {
$this->line->fk_fournprice = $fk_fournprice;
}
$this->line->fk_fournprice = $fk_fournprice;
$this->line->pa_ht = $pa_ht;
if (is_array($array_options) && count($array_options)>0) {
@ -3883,10 +3874,17 @@ class FactureLigne extends CommonInvoiceLine
if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente
if ($this->pa_ht == 0) {
if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{
return $result;
}
else
{
$this->pa_ht = $result;
}
}
// Check parameters
@ -3906,14 +3904,6 @@ class FactureLigne extends CommonInvoiceLine
}
}
// POS or by external module, take lowest buying price
if (!empty($this->fk_product) && empty($this->fk_fournprice) && empty($this->pa_ht)) {
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
$productFournisseur = new ProductFournisseur($this->db);
$productFournisseur->find_min_price_product_fournisseur($this->fk_product);
$this->fk_fournprice = $productFournisseur->product_fourn_price_id;
}
$this->db->begin();
// Insertion dans base de la ligne
@ -4081,10 +4071,17 @@ class FactureLigne extends CommonInvoiceLine
if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente
if ($this->pa_ht == 0) {
if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{
return $result;
}
else
{
$this->pa_ht = $result;
}
}
$this->db->begin();

View File

@ -201,7 +201,11 @@ if ($id)
}
}
// Formulaire saisie salaire
/* ************************************************************************** */
/* */
/* create mode */
/* */
/* ************************************************************************** */
if ($action == 'create')
{
$year_current = strftime("%Y",dol_now());
@ -231,50 +235,64 @@ if ($action == 'create')
print '<table class="border" width="100%">';
print "<tr>";
print '<td class="fieldrequired"><label for="datep">'.$langs->trans("DatePayment").'</label></td><td>';
// Date payment
print '<tr><td>';
print fieldLabel('DatePayment','datep',1).'</td><td>';
print $form->select_date((empty($datep)?-1:$datep),"datep",'','','','add',1,1);
print '</td></tr>';
print '<tr><td><label for="datev">'.$langs->trans("DateValue").'</label></td><td>';
// Date value for bank
print '<tr><td>';
print fieldLabel('DateValue','datev',0).'</td><td>';
print $form->select_date((empty($datev)?-1:$datev),"datev",'','','','add',1,1);
print '</td></tr>';
// Employee
print "<tr>";
print '<td class="fieldrequired"><label for="fk_user">'.$langs->trans("Employee").'</label></td><td>';
print '<tr><td>';
print fieldLabel('Employee','fk_user',1).'</td><td>';
print $form->select_dolusers(GETPOST('fk_user','int'),'fk_user',1);
print '</td></tr>';
// Label
print '<tr><td class="fieldrequired"><label for="label">'.$langs->trans("Label").'</label></td><td><input name="label" id="label" size="40" value="'.($_POST["label"]?$_POST["label"]:$langs->trans("SalaryPayment")).'"></td></tr>';
print '<tr><td>';
print fieldLabel('Label','label',1).'</td><td>';
print '<input name="label" id="label" size="40" value="'.($_POST["label"]?$_POST["label"]:$langs->trans("SalaryPayment")).'">';
print '</td></tr>';
print "<tr>";
print '<td class="fieldrequired"><label for="datesp">'.$langs->trans("DateStartPeriod").'</label></td><td>';
// Date start period
print '<tr><td>';
print fieldLabel('DateStartPeriod','datesp',1).'</td><td>';
print $form->select_date($datesp,"datesp",'','','','add');
print '</td></tr>';
print '<tr><td class="fieldrequired"><label for="dateep">'.$langs->trans("DateEndPeriod").'</label></td><td>';
// Date end period
print '<tr><td>';
print fieldLabel('DateEndPeriod','dateep',1).'</td><td>';
print $form->select_date($dateep,"dateep",'','','','add');
print '</td></tr>';
// Amount
print '<tr><td class="fieldrequired"><label for="amount">'.$langs->trans("Amount").'</label></td><td><input name="amount" id="amount" size="10" value="'.GETPOST("amount").'"></td></tr>';
print '<tr><td>';
print fieldLabel('Amount','amount',1).'</td><td>';
print '<input name="amount" id="amount" size="10" value="'.GETPOST("amount").'">';
print '</td></tr>';
// Bank
if (! empty($conf->banque->enabled))
{
print '<tr><td class="fieldrequired"><label for="selectaccountid">'.$langs->trans("Account").'</label></td><td>';
print '<tr><td>';
print fieldLabel('Account','selectaccountid',1).'</td><td>';
$form->select_comptes($_POST["accountid"],"accountid",0,'',1); // Affiche liste des comptes courant
print '</td></tr>';
}
// Type payment
print '<tr><td class="fieldrequired"><label for="selectpaymenttype">'.$langs->trans("PaymentMode").'</label></td><td>';
print '<tr><td>';
print fieldLabel('PaymentMode','selectpaymenttype',1).'</td><td>';
$form->select_types_paiements(GETPOST("paymenttype"), "paymenttype");
print "</td>\n";
print "</tr>";
print '</td></tr>';
// Number
if (! empty($conf->banque->enabled))
{
// Number
@ -304,7 +322,7 @@ if ($action == 'create')
/* ************************************************************************** */
/* */
/* Barre d'action */
/* View mode */
/* */
/* ************************************************************************** */
@ -322,8 +340,8 @@ if ($id)
print $object->ref;
print '</td></tr>';
// Person
print '<tr><td>'.$langs->trans("Person").'</td><td>';
// Employee
print '<tr><td>'.$langs->trans("Employee").'</td><td>';
$usersal=new User($db);
$usersal->fetch($object->fk_user);
print $usersal->getNomUrl(1);

View File

@ -1283,10 +1283,18 @@ class Contrat extends CommonObject
if (empty($pa_ht)) $pa_ht=0;
// si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente
if ($pa_ht == 0) {
if ($pu_ht > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
$pa_ht = $pu_ht * (1 - $remise_percent / 100);
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
{
if (($result = $this->defineBuyPrice($pu_ht, $remise_percent, $fk_product)) < 0)
{
return $result;
}
else
{
$pa_ht = $result;
}
}
// Insertion dans la base
@ -1456,10 +1464,17 @@ class Contrat extends CommonObject
if (empty($pa_ht)) $pa_ht=0;
// si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente
if ($pa_ht == 0) {
if ($pu > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
$pa_ht = $pu * (1 - $remise_percent / 100);
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
{
if (($result = $this->defineBuyPrice($pu_ht, $remise_percent)) < 0)
{
return $result;
}
else
{
$pa_ht = $result;
}
}
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet set description='".$this->db->escape($desc)."'";
@ -2481,12 +2496,20 @@ class ContratLigne extends CommonObjectLine
if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseigné et utilisé pour calcul des marges alors prix achat = prix vente
if ($this->pa_ht == 0) {
if ($this->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{
return $result;
}
else
{
$this->pa_ht = $result;
}
}
$this->db->begin();
// Update request

View File

@ -46,7 +46,12 @@ if ($action == 'print_file' and $user->rights->printing->read)
if (! empty($conf->global->{$printer->active})) {
$subdir=(GETPOST('printer', 'alpha')=='expedition'?'sending':'');
$ret = $printer->print_file(GETPOST('file', 'alpha'), GETPOST('printer', 'alpha'), $subdir);
$module = GETPOST('printer', 'alpha');
if ($module =='commande_fournisseur') {
$module = 'fournisseur';
$subdir = 'commande';
}
$ret = $printer->print_file(GETPOST('file', 'alpha'), $module, $subdir);
if ($ret > 0) {
//print '<pre>'.print_r($printer->errors, true).'</pre>';
setEventMessages($printer->error, $printer->errors, 'errors');

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -92,7 +92,7 @@ if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM
}
if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) && $user->rights->fournisseur->commande->lire)
{
$arrayresult['searchintosupplierorder']=array('text'=>img_picto('','object_propal').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php?search_all='.urlencode($search_boxvalue));
$arrayresult['searchintosupplierorder']=array('text'=>img_picto('','object_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php?search_all='.urlencode($search_boxvalue));
}
if (! empty($conf->askpricesupplier->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->askpricesupplier->lire)
{

View File

@ -3108,20 +3108,21 @@ abstract class CommonObject
$var=!$var;
if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line)))
//if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line)))
if (is_object($hookmanager)) // Old code is commented on preceding line.
{
if (empty($line->fk_parent_line))
{
$parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline);
$hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
}
else
{
$parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline);
$hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
$reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
}
}
else
if (empty($reshook))
{
$this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$extrafieldsline);
}
@ -3171,6 +3172,9 @@ abstract class CommonObject
{
$product_static = new Product($this->db);
$product_static->fetch($line->fk_product);
$product_static->ref = $line->ref; //can change ref in hook
$product_static->label = $line->label; //can change label in hook
$text=$product_static->getNomUrl(1);
// Define output language and label
@ -4176,4 +4180,66 @@ abstract class CommonObject
return true;
}
/**
* define buy price if not defined
* set buy price = sell price if ForceBuyingPriceIfNull configured,
* else if calculation MARGIN_TYPE = 'pmp' and pmp is calculated, set pmp as buyprice
* else set min buy price as buy price
*
* @param float $unitPrice product unit price
* @param float $discountPercent line discount percent
* @param int $fk_product product id
*
* @return float <0 if ko, buyprice if ok
*/
public function defineBuyPrice($unitPrice = 0, $discountPercent = 0, $fk_product = 0)
{
global $conf;
$buyPrice = 0;
if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1))
{
$buyPrice = $unitPrice * (1 - $discountPercent / 100);
}
else
{
// Get PMP
if (! empty($fk_product))
{
if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp')
{
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$product = new Product($this->db);
$result = $product->fetch($fk_product);
if ($result <= 0)
{
$this->error='ErrorProductIdDoesNotExists';
return -1;
}
if (($product->pmp > 0))
{
$buyPrice = $product->pmp;
}
// TODO add option to set PMP of product
}
else if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1')
{
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
$productFournisseur = new ProductFournisseur($this->db);
if (($result = $productFournisseur->find_min_price_product_fournisseur($fk_product)) > 0)
{
$buyPrice = $productFournisseur->fourn_price;
}
else
{
$this->error = $productFournisseur->error;
return -1;
}
}
}
}
return $buyPrice;
}
}

View File

@ -163,7 +163,9 @@ class HookManager
'printAddress',
'printSearchForm',
'formatEvent',
'addCalendarChoice'
'addCalendarChoice',
'printObjectLine',
'printObjectSubLine'
)
)) $hooktype='addreplace';
// Deprecated hook types ('returnvalue')

View File

@ -285,7 +285,7 @@ class FormFile
}
$printer=0;
if (in_array($modulepart,array('facture','askpricesupplier','propal','proposal','order','commande','expedition'))) // The direct print feature is implemented only for such elements
if (in_array($modulepart,array('facture','askpricesupplier','propal','proposal','order','commande','expedition', 'commande_fournisseur'))) // The direct print feature is implemented only for such elements
{
$printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled))?true:false;
}

View File

@ -108,7 +108,7 @@ class Ldap
{
global $conf;
//Server
// Server
if (! empty($conf->global->LDAP_SERVER_HOST)) $this->server[] = $conf->global->LDAP_SERVER_HOST;
if (! empty($conf->global->LDAP_SERVER_HOST_SLAVE)) $this->server[] = $conf->global->LDAP_SERVER_HOST_SLAVE;
$this->serverPort = $conf->global->LDAP_SERVER_PORT;
@ -120,9 +120,11 @@ class Ldap
$this->searchPassword = $conf->global->LDAP_ADMIN_PASS;
$this->people = $conf->global->LDAP_USER_DN;
$this->groups = $conf->global->LDAP_GROUP_DN;
$this->filter = $conf->global->LDAP_FILTER_CONNECTION;
//Users
$this->filter = $conf->global->LDAP_FILTER_CONNECTION; // Filter on user
$this->filtermember = $conf->global->LDAP_MEMBER_FILTER; // Filter on member
// Users
$this->attr_login = $conf->global->LDAP_FIELD_LOGIN; //unix
$this->attr_sambalogin = $conf->global->LDAP_FIELD_LOGIN_SAMBA; //samba, activedirectory
$this->attr_name = $conf->global->LDAP_FIELD_NAME;
@ -891,14 +893,14 @@ class Ldap
}
/**
* Returns an array containing a details of elements
* Returns an array containing a details or list of LDAP record(s)
* ldapsearch -LLLx -hlocalhost -Dcn=admin,dc=parinux,dc=org -w password -b "ou=adherents,ou=people,dc=parinux,dc=org" userPassword
*
* @param string $search Valeur champ cle recherche, sinon '*' pour tous.
* @param string $search Value of fiel to search, '*' for all. Not used if $activefilter is set.
* @param string $userDn DN (Ex: ou=adherents,ou=people,dc=parinux,dc=org)
* @param string $useridentifier Name of key field (Ex: uid)
* @param array $attributeArray Array of fields required. Note this array must also contains field $useridentifier (Ex: sn,userPassword)
* @param int $activefilter 1=use field this->filter as filter instead of parameter $search
* @param int $activefilter '1' or 'user'=use field this->filter as filter instead of parameter $search, 'member'=use field this->filtermember as filter
* @param array $attributeAsArray Array of fields wanted as an array not a string
* @return array Array of [id_record][ldap_field]=value
*/
@ -906,7 +908,7 @@ class Ldap
{
$fulllist=array();
dol_syslog(get_class($this)."::getRecords search=".$search." userDn=".$userDn." useridentifier=".$useridentifier." attributeArray=array(".join(',',$attributeArray).")");
dol_syslog(get_class($this)."::getRecords search=".$search." userDn=".$userDn." useridentifier=".$useridentifier." attributeArray=array(".join(',',$attributeArray).") activefilter=".$activefilter);
// if the directory is AD, then bind first with the search user first
if ($this->serverType == "activedirectory")
@ -916,15 +918,19 @@ class Ldap
}
// Define filter
if ($activefilter == 1)
if (! empty($activefilter))
{
if ($this->filter)
if (((string) $activefilter == '1' || (string) $activefilter == 'user') && $this->filter)
{
$filter = '('.$this->filter.')';
}
else
elseif (((string) $activefilter == 'member') && $this->filter)
{
$filter='('.$useridentifier.'=*)';
$filter = '('.$this->filtermember.')';
}
else // If this->filter is empty, make fiter on * (all)
{
$filter = '('.$useridentifier.'=*)';
}
}
else

View File

@ -179,6 +179,7 @@ function getBrowserInfo($user_agent)
// OS
if (preg_match('/linux/i', $user_agent)) { $os='linux'; }
elseif (preg_match('/macintosh/i', $user_agent)) { $os='macintosh'; }
// Name
if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='firefox'; $version=$reg[2]; }
@ -703,7 +704,7 @@ function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto
function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0)
{
global $conf,$langs, $hookmanager;
$out="\n".'<div class="tabs" data-role="controlgroup" data-type="horizontal">'."\n";
// Show title
@ -733,7 +734,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi
$displaytab=0;
$nbintab=0;
$popuptab=0;
for ($i = 0 ; $i <= $maxkey ; $i++)
{
if ((is_numeric($active) && $i == $active) || (! empty($links[$i][2]) && ! is_numeric($active) && $active == $links[$i][2]))
@ -777,7 +778,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi
else
{
// The popup with the other tabs
if (! $popuptab)
if (! $popuptab)
{
$popuptab=1;
$outmore.='<div class="popuptabset">';
@ -795,13 +796,13 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi
$outmore.='<a'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="inline-block" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
$outmore.='</div>';
$nbintab++;
}
$displaytab=$i;
}
if ($popuptab) $outmore.='</div>';
if ($displaytab > $limittoshow)
{
$tabsname=str_replace("@", "", $picto);
@ -817,7 +818,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi
}
$out.="</div>\n";
if (! $notab) $out.="\n".'<div class="tabBar">'."\n";
$parameters=array('tabname' => $active);
@ -900,7 +901,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
print '</div>';
print '<div class="underrefbanner clearboth"></div>';
}
/**
* Show a string with the label tag dedicated to the HTML edit field.
*
@ -1382,7 +1383,7 @@ function dol_print_size($size,$shortvalue=0,$shortunit=0)
function dol_print_url($url,$target='_blank',$max=32,$withpicto=0)
{
global $langs;
if (empty($url)) return '';
$link='<a href="';
@ -1675,7 +1676,7 @@ function dol_print_address($address, $htmlid, $mode, $id, $noprint=0)
global $conf, $user, $langs, $hookmanager;
$out = '';
if ($address)
{
if ($hookmanager) {
@ -1683,7 +1684,7 @@ function dol_print_address($address, $htmlid, $mode, $id, $noprint=0)
$reshook = $hookmanager->executeHooks('printAddress', $parameters, $address);
$out.=$hookmanager->resPrint;
}
if (empty($reshook))
if (empty($reshook))
{
$out.=nl2br($address);
$showgmap=$showomap=0;
@ -2748,7 +2749,7 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m
$sortorder=strtoupper($sortorder);
$out='';
$sortimg='';
$tag='th';
if ($thead==2) $tag='div';
@ -2815,9 +2816,9 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m
$sortimg.= '</span>';
}
$out.=$sortimg;
$out.='</'.$tag.'>';
return $out;
@ -2958,7 +2959,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so
if ($cpt > 2) $pagelist.='<li'.(empty($conf->dol_use_jmobile)?' class="pagination"':'').'><span '.(empty($conf->dol_use_jmobile)?'class="inactive"':'data-role="button"').'>...</span></li>';
else if ($cpt == 2) $pagelist.='<li'.(empty($conf->dol_use_jmobile)?' class="pagination"':'').'><a '.(empty($conf->dol_use_jmobile)?'':'data-role="button" ').'href="'.$file.'?page=1'.$options.'&amp;sortfield='.$sortfield.'&amp;sortorder='.$sortorder.'">2</a></li>';
}
do
{
if ($cpt==$page)
@ -2972,7 +2973,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so
$cpt++;
}
while ($cpt < $nbpages && $cpt<=$page+$maxnbofpage);
if ($cpt<$nbpages)
{
if ($cpt<$nbpages-2) $pagelist.= '<li'.(empty($conf->dol_use_jmobile)?' class="pagination"':'').'><span '.(empty($conf->dol_use_jmobile)?'class="inactive"':'data-role="button"').'>...</span></li>';
@ -4402,7 +4403,7 @@ function dolGetFirstLastname($firstname,$lastname,$nameorder=-1)
}
else if ($nameorder == 2)
{
$ret.=$firstname;
$ret.=$firstname;
}
else
{
@ -5225,7 +5226,7 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
/**
* Return the filename of file to get the thumbs
*
*
* @param string $file Original filename
* @param string $extName Extension to differenciate thumb file name ('', '_small', '_mini')
* @param string $extImgTarget Force image format for thumbs. Use '' to keep same extension than original image.
@ -5235,10 +5236,10 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='')
{
$dirName = dirname($file);
if ($dirName == '.') $dirName='';
$fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse
$fileName = basename($fileName);
if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpg$/i',$file)?'.jpg':'');
if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpeg$/i',$file)?'.jpeg':'');
if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.gif$/i',$file)?'.gif':'');
@ -5246,9 +5247,9 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='')
if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.bmp$/i',$file)?'.bmp':'');
if (! $extImgTarget) return $file;
$subdir='';
if ($extName) $subdir = 'thumbs/';
return $dirName.$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb
}

View File

@ -3,6 +3,7 @@
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2009-2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
*
* 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
@ -132,18 +133,6 @@ function product_prepare_head($object)
$head[$h][2] = 'documents';
$h++;
// More tabs from canvas
// TODO Is this still used ?
if (isset($object->onglets) && is_array($object->onglets))
{
foreach ($object->onglets as $onglet)
{
$head[$h] = $onglet;
$h++;
}
}
complete_head_from_modules($conf,$langs,$object,$head,$h,'product', 'remove');
return $head;
@ -166,6 +155,16 @@ function product_admin_prepare_head()
$head[$h][2] = 'general';
$h++;
if (!empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL))
{
$head[$h] = array(
0 => DOL_URL_ROOT."/product/admin/price_rules.php",
1 => $langs->trans('MultipriceRules'),
2 => 'generator'
);
$h++;
}
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab

View File

@ -977,7 +977,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td class="nowrap">';
print '<td>';
$projectstatic->ref=$objp->ref;
print $projectstatic->getNomUrl(1);
print ' - '.dol_trunc($objp->title,24).'</td>';

View File

@ -62,7 +62,7 @@ class modWebsite extends DolibarrModules
// Config pages
//-------------
$this->config_page_url = array("website.php");
$this->config_page_url = array();
// Dependancies
//-------------

View File

@ -414,7 +414,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
elseif ($action == 'MEMBER_CREATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->global->LDAP_MEMBER_ACTIVE))
if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
{
$ldap=new Ldap();
$ldap->connect_bind();
@ -433,7 +433,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
elseif ($action == 'MEMBER_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->global->LDAP_MEMBER_ACTIVE))
if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
{
// If status field is setup to be synchronized
if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
@ -457,7 +457,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
elseif ($action == 'MEMBER_SUBSCRIPTION')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->global->LDAP_MEMBER_ACTIVE))
if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
{
// If subscriptions fields are setup to be synchronized
if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE
@ -485,7 +485,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
elseif ($action == 'MEMBER_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->global->LDAP_MEMBER_ACTIVE))
if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
{
$ldap=new Ldap();
$ldap->connect_bind();
@ -522,7 +522,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
elseif ($action == 'MEMBER_NEW_PASSWORD')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->global->LDAP_MEMBER_ACTIVE))
if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
{
// If password field is setup to be synchronized
if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED)
@ -546,7 +546,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
elseif ($action == 'MEMBER_RESILIATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->global->LDAP_MEMBER_ACTIVE))
if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
{
// If status field is setup to be synchronized
if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
@ -570,7 +570,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
elseif ($action == 'MEMBER_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->global->LDAP_MEMBER_ACTIVE))
if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
{
$ldap=new Ldap();
$ldap->connect_bind();

View File

@ -121,26 +121,38 @@ class ProductFournisseur extends Product
*/
function remove_product_fournisseur_price($rowid)
{
global $conf;
global $conf, $user;
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql.= " WHERE rowid = ".$rowid;
// Call trigger
$result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE',$user);
if ($result < 0) $error++;
// End call triggers
dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
if (empty($error))
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql.= " WHERE rowid = ".$rowid;
dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
$this->error=$this->db->lasterror();
$error++;
}
}
if (empty($error)){
$this->db->commit();
return 1;
}
else
{
$this->error=$this->db->lasterror();
}else{
$this->db->rollback();
return -1;
}
}

View File

@ -872,6 +872,8 @@ if (empty($reshook))
}
}
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
/*
* Create an order

View File

@ -26,9 +26,9 @@
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(1, 5,'EXECBOARD', 'Executive board', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(2, 10, 'MANAGDIR', 'Managing director', 1, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(3, 15, 'ACCOUNTMANAG', 'Account manager', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(3, 20, 'ENGAGDIR', 'Engagement director', 1, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(4, 25, 'DIRECTOR', 'Director', 1, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(5, 30, 'PROJMANAG', 'Project manager', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(6, 35, 'DEPHEAD', 'Department head', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(7, 40, 'SECRETAR', 'Secretary', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(8, 45, 'EMPLOYEE', 'Department employee', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(4, 20, 'ENGAGDIR', 'Engagement director', 1, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(5, 25, 'DIRECTOR', 'Director', 1, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(6, 30, 'PROJMANAG', 'Project manager', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(7, 35, 'DEPHEAD', 'Department head', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(8, 40, 'SECRETAR', 'Secretary', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(9, 45, 'EMPLOYEE', 'Department employee', 0, 1);

View File

@ -71,7 +71,6 @@ ALTER TABLE llx_contrat ADD COLUMN ref_customer varchar(30);
ALTER TABLE llx_commande ADD COLUMN fk_warehouse integer DEFAULT NULL after fk_shipping_method;
ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(750);
ALTER TABLE llx_ecm_directories DROP INDEX idx_ecm_directories;
ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX uk_ecm_directories (label, fk_parent, entity);
--ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX uk_ecm_directories_fullpath(fullpath);
@ -106,21 +105,6 @@ ALTER TABLE llx_product ADD COLUMN onportal tinyint DEFAULT 0 after tobuy;
ALTER TABLE llx_user ADD COLUMN employee tinyint DEFAULT 1;
create table llx_stock_lotserial
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
datec datetime,
tms timestamp,
fk_user_creat integer,
fk_user_modif integer,
fk_product integer NOT NULL, -- Id of product
batch varchar(30) DEFAULT NULL, -- Lot or serial number
eatby date DEFAULT NULL, -- Eatby date
sellby date DEFAULT NULL -- Sellby date
) ENGINE=innodb;
CREATE TABLE IF NOT EXISTS llx_c_hrm_function
(
rowid integer PRIMARY KEY,
@ -134,12 +118,12 @@ CREATE TABLE IF NOT EXISTS llx_c_hrm_function
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(1, 5, 'EXECBOARD', 'Executive board', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(2, 10, 'MANAGDIR', 'Managing director', 1, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(3, 15, 'ACCOUNTMANAG', 'Account manager', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(3, 20, 'ENGAGDIR', 'Engagement director', 1, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(4, 25, 'DIRECTOR', 'Director', 1, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(5, 30, 'PROJMANAG', 'Project manager', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(6, 35, 'DEPHEAD', 'Department head', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(7, 40, 'SECRETAR', 'Secretary', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(8, 45, 'EMPLOYEE', 'Department employee', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(4, 20, 'ENGAGDIR', 'Engagement director', 1, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(5, 25, 'DIRECTOR', 'Director', 1, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(6, 30, 'PROJMANAG', 'Project manager', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(7, 35, 'DEPHEAD', 'Department head', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(8, 40, 'SECRETAR', 'Secretary', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(9, 45, 'EMPLOYEE', 'Department employee', 0, 1);
CREATE TABLE IF NOT EXISTS llx_c_hrm_department
(
@ -247,7 +231,7 @@ ALTER TABLE llx_budget_lines ADD UNIQUE INDEX uk_budget_lines (fk_budget, fk_pro
-- MYSQL V4 DELETE llx_budget_lines FROM llx_budget_lines LEFT JOIN llx_budget ON llx_budget.rowid = llx_budget_lines.fk_budget WHERE llx_budget_lines.rowid IS NULL;
-- POSTGRESQL V8 DELETE FROM llx_budget_lines USING llx_budget WHERE llx_budget_lines.fk_budget NOT IN (SELECT llx_budget.rowid FROM llx_budget);
ALTER TABLE llx_budget_lines ADD INDEX idx_budget_lines (fk_projet);
ALTER TABLE llx_budget_lines ADD INDEX idx_budget_lines (fk_project);
ALTER TABLE llx_budget_lines ADD CONSTRAINT fk_budget_lines_budget FOREIGN KEY (fk_budget) REFERENCES llx_budget (rowid);
@ -255,3 +239,15 @@ ALTER TABLE llx_budget_lines ADD CONSTRAINT fk_budget_lines_budget FOREIGN KEY (
ALTER TABLE llx_c_typent ADD COLUMN position integer NOT NULL DEFAULT 0;
ALTER TABLE llx_c_forme_juridique ADD COLUMN position integer NOT NULL DEFAULT 0;
ALTER TABLE llx_c_type_fees ADD COLUMN position integer NOT NULL DEFAULT 0;
-- NEW Level multiprice generator based on per cent variations over base price
CREATE TABLE llx_product_pricerules
(
rowid INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
level INT NOT NULL, -- Which price level is this rule for?
fk_level INT NOT NULL, -- Price variations are made over price of X
var_percent FLOAT NOT NULL, -- Price variation over based price
var_min_percent FLOAT NOT NULL -- Min price discount over general price
);
ALTER TABLE llx_product ADD COLUMN price_autogen TINYINT(1) DEFAULT 0;
ALTER TABLE llx_product_pricerules ADD CONSTRAINT unique_level UNIQUE (level);

View File

@ -46,7 +46,7 @@ create table llx_product
price_base_type varchar(3) DEFAULT 'HT',
tva_tx double(6,3), -- Default VAT rate of product
recuperableonly integer NOT NULL DEFAULT '0', -- French NPR VAT
localtax1_tx double(6,3) DEFAULT 0, -- Spanish local VAT 1
localtax1_tx double(6,3) DEFAULT 0, -- Spanish local VAT 1
localtax2_tx double(6,3) DEFAULT 0, -- Spanish local VAT 2
fk_user_author integer DEFAULT NULL, -- user making creation
fk_user_modif integer, -- user making last change
@ -81,5 +81,6 @@ create table llx_product
import_key varchar(14), -- Import key
fk_price_expression integer, -- Link to the rule for dynamic price calculation
desiredstock integer DEFAULT 0,
fk_unit integer DEFAULT NULL
fk_unit integer DEFAULT NULL,
price_autogen TINYINT DEFAULT 0
)ENGINE=innodb;

View File

@ -0,0 +1,19 @@
-- ============================================================================
-- Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
--
-- 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/>.
--
-- ===========================================================================
ALTER TABLE llx_product_pricerules ADD CONSTRAINT unique_level UNIQUE (level);

View File

@ -0,0 +1,26 @@
-- ============================================================================
-- Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
--
-- 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/>.
--
-- ===========================================================================
CREATE TABLE llx_product_pricerules
(
rowid INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
level INT NOT NULL, -- Which price level is this rule for?
fk_level INT NOT NULL, -- Price variations are made over price of X
var_percent FLOAT NOT NULL, -- Price variation over based price
var_min_percent FLOAT NOT NULL -- Min price discount over general price
);

View File

@ -1708,3 +1708,4 @@ TitleExampleForMajorRelease=Example of message you can use to announce this majo
TitleExampleForMaintenanceRelease=Example of message you can use to announce this maintenance release (feel free to use it on your web sites)
ExampleOfNewsMessageForMajorRelease=Dolibarr ERP & CRM %s is available. Version %s is a major release with a lot of new features for both users and developers. You can download it from the download area of http://www.dolibarr.org portal (subdirectory Stable versions). You can read <a href="https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog">ChangeLog</a> for complete list of changes.
ExampleOfNewsMessageForMaintenanceRelease=Dolibarr ERP & CRM %s is available. Version %s is a maintenance version, so it contains only fixes of bugs. We recommend everybody using an older version to upgrade to this one. As any maintenance release, no new features, nor data structure change is present into this version. You can download it from the download area of http://www.dolibarr.org portal (subdirectory Stable versions). You can read <a href="https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog">ChangeLog</a> for complete list of changes.
MultiPriceRuleDesc=When option "Several level of prices per product/service" is on, you can define different prices (one per price level) for each product. To save you time, you can enter here rule to have price for each level autocalculated according to price of first level, so you will have to enter only price for first level on each product. This page is here to save you time and can be usefull only if your prices for each leve are relative to first level. You can ignore this page in most cases.

View File

@ -173,6 +173,7 @@ ErrorFieldMustBeAnInteger=Field <b>%s</b> must be an integer
ErrorMandatoryParametersNotProvided=Mandatory parameter(s) not provided
ErrorOppStatusRequiredIfAmount=You set an estimated amount for this opportunity/lead. So you must also enter its status
ErrorBadDefinitionOfMenuArrayInModuleDescriptor=Bad Definition Of Menu Array In Module Descriptor (bad value for key fk_menu)
ErrorSavingChanges=An error has ocurred when saving the changes
# Warnings
WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user.

View File

@ -24,7 +24,7 @@ StartDate=Start date
EndDate=End date
Launch=Start
ForceBuyingPriceIfNull=Force buying price if null
ForceBuyingPriceIfNullDetails=if "ON", margin will be zero on line (buying price = selling price), otherwise ("OFF"), marge will be equal to selling price (buying price = 0)
ForceBuyingPriceIfNullDetails=if "ON", margin will be zero on line (buying price = selling price), otherwise ("OFF"), marge will be equal to suggested default.
MARGIN_METHODE_FOR_DISCOUNT=Margin method for global discounts
UseDiscountAsProduct=As a product
UseDiscountAsService=As a service

View File

@ -23,3 +23,9 @@ PAYPAL_PAYONLINE_SENDEMAIL=EMail to warn after a payment (success or not)
ReturnURLAfterPayment=Return URL after payment
ValidationOfPaypalPaymentFailed=Validation of Paypal payment failed
PaypalConfirmPaymentPageWasCalledButFailed=Payment confirmation page for Paypal was called by Paypal but confirmation failed
SetExpressCheckoutAPICallFailed=SetExpressCheckout API call failed.
DoExpressCheckoutPaymentAPICallFailed=DoExpressCheckoutPayment API call failed.
DetailedErrorMessage=Detailed Error Message
ShortErrorMessage=Short Error Message
ErrorCode=Error Code
ErrorSeverityCode=Error Severity Code

View File

@ -69,6 +69,7 @@ ProductStatusNotOnBuyShort=Not for purchase
UpdatePrice=Update price
UpdateVAT=Update vat
UpdateDefaultPrice=Update default price
UpdateLevelPrices=Update prices for each level
AppliedPricesFrom=Applied prices from
SellingPrice=Selling price
SellingPriceHT=Selling price (net of tax)
@ -235,6 +236,10 @@ PriceByQuantityRange=Quantity range
ProductsDashboard=Products/Services summary
UpdateOriginalProductLabel=Modify original label
HelpUpdateOriginalProductLabel=Allows to edit the name of the product
MultipriceRules=Price level rules
UseMultipriceRules=Use price level rules (defined into product module setup) to autocalculate prices of all other level according to first level
PercentVariationOver=%% variation over %s
PercentDiscountOver=%% discount over %s
### composition fabrication
Building=Production and items dispatchment
Build=Produce

View File

@ -406,11 +406,11 @@ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$re
$ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
$ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
echo "SetExpressCheckout API call failed. <br>\n";
echo "Detailed Error Message: " . $ErrorLongMsg." <br>\n";
echo "Short Error Message: " . $ErrorShortMsg." <br>\n";
echo "Error Code: " . $ErrorCode." <br>\n";
echo "Error Severity Code: " . $ErrorSeverityCode." <br>\n";
echo $langs->trans('SetExpressCheckoutAPICallFailed') . "<br>\n";
echo $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."<br>\n";
echo $langs->trans('ShortErrorMessage') . ": " . $ErrorShortMsg."<br>\n";
echo $langs->trans('ErrorCode') . ": " . $ErrorCode."<br>\n";
echo $langs->trans('ErrorSeverityCode') . ": " . $ErrorSeverityCode."<br>\n";
}
}

View File

@ -0,0 +1,205 @@
<?php
/**
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com
*
* 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/>.
*
* Page to set how to autocalculate price for each level when option
* PRODUCT_MULTIPRICE is on.
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
$langs->load("admin");
$langs->load("products");
// Security check
if (! $user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled)))
accessforbidden();
/**
* Actions
*/
if ($_POST) {
$var_percent = GETPOST('var_percent', 'array');
$var_min_percent = GETPOST('var_min_percent', 'array');
$fk_level = GETPOST('fk_level', 'array');
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
$check = isset($var_min_percent[$i]);
if ($i != 1) {
$check = $check && isset($var_percent[$i]) && isset($fk_level[$i]);
}
if (!$check) {
continue;
}
if ($i != 1) {
$i_var_percent = (float) price2num($var_percent[$i]);
} else {
$i_var_percent = 0;
}
$i_var_min_percent = (float) price2num($var_min_percent[$i]);
$i_fk_level = (int) $fk_level[$i];
if ($i == 1) {
$check1 = true;
$check2 = $i_var_min_percent;
} else {
$check1 = $i_fk_level >= 1 && $i_fk_level <= $conf->global->PRODUIT_MULTIPRICES_LIMIT;
$check2 = $i_var_percent && $i_var_min_percent;
}
if (!$check1 || !$check2) {
//If the level is between range but percent fields are empty, then we ensure it does not exist in DB
if ($check1 && !$check2) {
$db->query("DELETE FROM ".MAIN_DB_PREFIX."product_pricerules WHERE level = ".(int) $i);
}
continue;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_pricerules
SET level = ".(int) $i.", fk_level = ".$db->escape($i_fk_level).", var_percent = ".$i_var_percent.", var_min_percent = ".$i_var_min_percent;
if (!$db->query($sql)) {
//If we could not create, then we try updating
$sql = "UPDATE ".MAIN_DB_PREFIX."product_pricerules
SET fk_level = ".$db->escape($i_fk_level).", var_percent = ".$i_var_percent.", var_min_percent = ".$i_var_min_percent." WHERE level = ".$i;
if (!$db->query($sql)) {
setEventMessage($langs->trans('ErrorSavingChanges'), 'errors');
}
}
}
setEventMessage($langs->trans("RecordSaved"));
}
/*
* View
*/
$sql = "SELECT * FROM ".MAIN_DB_PREFIX."product_pricerules";
$query = $db->query($sql);
$rules = array();
while ($result = $db->fetch_object($query)) {
$rules[$result->level] = $result;
}
$title = $langs->trans('ProductServiceSetup');
$tab = $langs->trans("ProductsAndServices");
if (empty($conf->produit->enabled)) {
$title = $langs->trans('ServiceSetup');
$tab = $langs->trans('Services');
} elseif (empty($conf->service->enabled)) {
$title = $langs->trans('ProductSetup');
$tab = $langs->trans('Products');
}
llxHeader('', $langs->trans('MultipriceRules'));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($title,$linkback,'title_setup');
print '<form method="POST">';
$head = product_admin_prepare_head();
dol_fiche_head($head, 'generator', $tab, 0, 'product');
print $langs->trans("MultiPriceRuleDesc").'<br><br>';
print load_fiche_titre($langs->trans('MultipriceRules'), '', '');
//Array that contains the number of prices available
$price_options = array();
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
$price_options[$i] = $langs->trans('SellingPrice').' '.$i;
}
$genPriceOptions = function($level) use ($price_options) {
$return = array();
for ($i = 1; $i < $level; $i++) {
$return[$i] = $price_options[$i];
}
return $return;
};
?>
<table class="noborder">
<tr class="liste_titre">
<td style="text-align: center"><?php echo $langs->trans('PriceLevel') ?></td>
<td style="text-align: center"><?php echo $langs->trans('Price') ?></td>
<td style="text-align: center"><?php echo $langs->trans('MinPrice') ?></td></tr>
<tr>
<td class="fieldrequired" style="text-align: center"><?php echo $langs->trans('SellingPrice') ?> 1</td>
<td></td>
<td style="text-align: center"><input type="text" style="text-align: right" name="var_min_percent[1]" size="5" value="<?php echo isset($rules[1]) ? price($rules[1]->var_min_percent, 2) : '' ?>"> <?php echo $langs->trans('PercentDiscountOver', $langs->trans('SellingPrice').' 1') ?></td>
</tr>
<?php for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++): ?>
<tr>
<td class="fieldrequired" style="text-align: center"><?php
echo $langs->trans('SellingPrice').' '.$i;
// Label of price
if (! empty($conf->global->{"PRODUIT_MULTIPRICES_LABEL$i"})) {
print ' - '.$langs->trans($conf->global->$keyforlabel);
}
?>
</td>
<td style="text-align: center">
<input type="text" style="text-align: right" name="var_percent[<?php echo $i ?>]" size="5" value="<?php echo isset($rules[$i]) ? price($rules[$i]->var_percent, 2) : '' ?>">
<?php echo $langs->trans('PercentVariationOver', Form::selectarray("fk_level[$i]", $genPriceOptions($i), (isset($rules[$i]) ? $rules[$i]->fk_level : null))) ?>
</td>
<td style="text-align: center">
<input type="text" style="text-align: right" name="var_min_percent[<?php echo $i ?>]" size="5" value="<?php echo isset($rules[$i]) ? price($rules[$i]->var_min_percent, 2) : '' ?>">
<?php echo $langs->trans('PercentDiscountOver', $langs->trans('SellingPrice').' '.$i) ?>
</td>
</tr>
<?php endfor ?>
</table>
<?php
dol_fiche_end();
print '<div style="text-align: center">
<input type="submit" value="'.$langs->trans('Save').'" class="button">
</div>';
print '</form>';
llxFooter();
$db->close();

View File

@ -191,6 +191,12 @@ class Product extends CommonObject
*/
public $fk_unit;
/**
* Price is generated using multiprice rules
* @var int
*/
public $price_autogen = 0;
/**
* Regular product
*/
@ -710,6 +716,7 @@ class Product extends CommonObject
$sql.= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell)."'";
$sql.= ", desiredstock = " . ((isset($this->desiredstock) && $this->desiredstock != '') ? $this->desiredstock : "null");
$sql.= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql.= ", price_autogen = " . (!$this->price_autogen ? 0 : 1);
$sql.= " WHERE rowid = " . $id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
@ -1337,9 +1344,10 @@ class Product extends CommonObject
* @param int $level 0=standard, >0 = level if multilevel prices
* @param int $newnpr 0=Standard vat rate, 1=Special vat rate for French NPR VAT
* @param int $newpsq 1 if it has price by quantity
* @param int $ignore_autogen Used to avoid infinite loops
* @return int <0 if KO, >0 if OK
*/
function updatePrice($newprice, $newpricebase, $user, $newvat='',$newminprice='', $level=0, $newnpr=0, $newpsq=0)
function updatePrice($newprice, $newpricebase, $user, $newvat='',$newminprice='', $level=0, $newnpr=0, $newpsq=0, $ignore_autogen=0)
{
global $conf,$langs;
@ -1353,6 +1361,14 @@ class Product extends CommonObject
// Check parameters
if ($newvat == '') $newvat=$this->tva_tx;
// If multiprices are enabled, then we check if the current product is subject to price autogeneration
// Price will be modified ONLY when the first one is the one that is being modified
if (!empty($conf->global->PRODUIT_MULTIPRICES) && !$ignore_autogen && $this->price_autogen && ($level == 1))
{
return $this->generateMultiprices($user, $newprice, $newpricebase, $newvat, $newnpr, $newpsq);
}
if (! empty($newminprice) && ($newminprice > $newprice))
{
$this->error='ErrorPriceCantBeLowerThanMinPrice';
@ -1531,7 +1547,7 @@ class Product extends CommonObject
$sql.= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,";
$sql.= " accountancy_code_buy, accountancy_code_sell, stock, pmp,";
$sql.= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit";
$sql.= " , fk_price_expression";
$sql.= " , fk_price_expression, price_autogen";
$sql.= " FROM ".MAIN_DB_PREFIX."product";
if ($id) $sql.= " WHERE rowid = ".$this->db->escape($id);
else
@ -1608,6 +1624,7 @@ class Product extends CommonObject
$this->ref_ext = $obj->ref_ext;
$this->fk_price_expression = $obj->fk_price_expression;
$this->fk_unit = $obj->fk_unit;
$this->price_autogen = $obj->price_autogen;
$this->db->free($resql);
@ -3992,4 +4009,65 @@ class Product extends CommonObject
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
/**
* Generates prices for a product based on product multiprice generation rules
*
* @param User $user User that updates the prices
* @param float $baseprice Base price
* @param string $price_type Base price type
* @param float $price_vat VAT % tax
* @param int $npr NPR
* @param string $psq ¿?
* @return int -1 KO, 1 OK
*/
public function generateMultiprices(User $user, $baseprice, $price_type, $price_vat, $npr, $psq)
{
global $conf, $db;
// FIXME USing * into select is forbidden
$sql = "SELECT * FROM ".MAIN_DB_PREFIX."product_pricerules";
$query = $db->query($sql);
$rules = array();
while ($result = $db->fetch_object($query)) {
$rules[$result->level] = $result;
}
//Because prices can be based on other level's prices, we temporarily store them
$prices = array(
1 => $baseprice
);
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
$price = $baseprice;
$price_min = 0;
if ($i > 1) {
//We have to make sure it does exist and it is > 0
if (isset($rules[$i]->var_percent) && $rules[$i]->var_percent) {
$price = $prices[$rules[$i]->fk_level] * (1 + ($rules[$i]->var_percent/100));
}
}
$prices[$i] = $price;
//We have to make sure it does exist and it is > 0
if (isset($rules[$i]->var_min_percent) && $rules[$i]->var_min_percent) {
$price_min = $price * (1 - ($rules[$i]->var_min_percent/100));
}
if ($price == $this->multiprices[$i] && ($price_min == $this->multiprices_min[$i])) {
continue;
}
if ($this->updatePrice($price, $price_type, $user, $price_vat, $price_min, $i, $npr, $psq, true) < 0) {
return -1;
}
}
return 1;
}
}

View File

@ -95,9 +95,14 @@ if (empty($reshook))
{
if ($rowid)
{
$result=$object->remove_product_fournisseur_price($rowid);
$action = '';
setEventMessage($langs->trans("PriceRemoved"));
$result=$product->remove_product_fournisseur_price($rowid);
if($result > 0){
setEventMessage($langs->trans("PriceRemoved"));
}else{
$error++;
setEventMessages($product->error, $product->errors, 'errors');
}
}
}

View File

@ -115,35 +115,35 @@ if (empty($reshook))
if (($action == 'update_price') && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer))
{
$newprice = '';
$newprice_min = '';
$newpricebase = '';
$newvat = '';
$maxpricesupplier = $object->min_recommended_price();
$object->fk_price_expression = empty($eid) ? 0 : $eid; //0 discards expression
// MultiPrix
if (! empty($conf->global->PRODUIT_MULTIPRICES))
{
$newprice = '';
$newprice_min = '';
$newpricebase = '';
$newvat = '';
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
{
if (isset($_POST ["price_" . $i]))
{
//Shall we generate prices using price rules?
$object->price_autogen = GETPOST('usePriceRules') == 'on' ? true : false;
$object->update($object->id, $user);
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) {
if (isset($_POST ["price_".$i])) {
$level = $i;
$newprice = price2num($_POST ["price_" . $i], 'MU');
$newprice_min = price2num($_POST ["price_min_" . $i], 'MU');
$newpricebase = $_POST ["multiprices_base_type_" . $i];
$newnpr = (preg_match('/\*/', $_POST ["tva_tx_" . $i]) ? 1 : 0);
$newvat = str_replace('*', '', $_POST ["tva_tx_" . $i]);
$newprice = price2num($_POST ["price_".$i], 'MU');
$newprice_min = price2num($_POST ["price_min_".$i], 'MU');
$newpricebase = $_POST ["multiprices_base_type_".$i];
$newnpr = (preg_match('/\*/', $_POST ["tva_tx_".$i]) ? 1 : 0);
$newvat = str_replace('*', '', $_POST ["tva_tx_".$i]);
$newpsq = GETPOST('psqflag');
$newpsq = empty($newpsq) ? 0 : $newpsq;
break; // We found submited price
}
}
}
else
{
} else {
$level = 0;
$newprice = price2num($_POST ["price"], 'MU');
$newprice_min = price2num($_POST ["price_min"], 'MU');
@ -154,42 +154,39 @@ if (empty($reshook))
$newpsq = empty($newpsq) ? 0 : $newpsq;
}
if (! empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier)
{
setEventMessage($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')),'errors');
$error++;
$action='edit_price';
if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier) {
setEventMessage($langs->trans("MinimumPriceLimit", price($maxpricesupplier, 0, '', 1, - 1, - 1, 'auto')), 'errors');
$error ++;
$action = 'edit_price';
}
if ($newprice < $newprice_min && ! empty($object->fk_price_expression))
{
if ($newprice < $newprice_min && !empty($object->fk_price_expression)) {
$newprice = $newprice_min; //Set price same as min, the user will not see the
}
if ($object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq) > 0)
{
$res = $object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq);
if ($res) {
if ($object->fk_price_expression != 0) {
//Check the expression validity by parsing it
$priceparser = new PriceParser($db);
$price_result = $priceparser->parseProduct($object);
if ($price_result < 0) { //Expression is not valid
$error++;
$action='edit_price';
$error ++;
$action = 'edit_price';
setEventMessage($priceparser->translatedError(), 'errors');
}
}
if (empty($error) && ! empty($conf->dynamicprices->enabled))
{
$ret=$object->setPriceExpression($object->fk_price_expression);
if ($ret < 0)
{
$error++;
$action='edit_price';
if (empty($error) && !empty($conf->dynamicprices->enabled)) {
$ret = $object->setPriceExpression($object->fk_price_expression);
if ($ret < 0) {
$error ++;
$action = 'edit_price';
setEventMessage($object->error, 'errors');
}
}
if (empty($error))
{
if (empty($error)) {
$action = '';
setEventMessage($langs->trans("RecordSaved"));
}
@ -199,6 +196,7 @@ if (empty($reshook))
}
}
if ($action == 'delete' && $user->rights->produit->supprimer)
{
$result = $object->log_price_delete($user, $_GET ["lineid"]);
@ -718,28 +716,30 @@ if (! $action || $action == 'delete' || $action == 'showlog_customer_price' || $
{
print "\n" . '<div class="tabsAction">' . "\n";
if (empty($conf->global->PRODUIT_MULTIPRICES))
if (empty($conf->global->PRODUIT_MULTIPRICES)) // For everyone, except multiprices
{
if ($user->rights->produit->creer || $user->rights->service->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=edit_price&amp;id=' . $object->id . '">' . $langs->trans("UpdateDefaultPrice") . '</a></div>';
}
}
else
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
{
if ($user->rights->produit->creer || $user->rights->service->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=add_customer_price&amp;id=' . $object->id . '">' . $langs->trans("AddCustomerPrice") . '</a></div>';
}
}
if (! empty($conf->global->PRODUIT_MULTIPRICES))
{
if ($user->rights->produit->creer || $user->rights->service->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=edit_vat&amp;id=' . $object->id . '">' . $langs->trans("UpdateVAT") . '</a></div>';
}
if ($user->rights->produit->creer || $user->rights->service->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=edit_price&amp;id=' . $object->id . '">' . $langs->trans("UpdateDefaultPrice") . '</a></div>';
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=edit_price&amp;id=' . $object->id . '">' . $langs->trans("UpdateLevelPrices") . '</a></div>';
}
}
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
{
if ($user->rights->produit->creer || $user->rights->service->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=add_customer_price&amp;id=' . $object->id . '">' . $langs->trans("AddCustomerPrice") . '</a></div>';
}
}
print "\n</div>\n";
}
@ -889,11 +889,41 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
{
dol_fiche_head('');
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
?>
<script>
var showHidePriceRules = function () {
var otherPrices = $('div.fiche form:not(:first)');
var minPrice1 = $('div.fiche form:first tr:eq(3)');
if (jQuery('input#usePriceRules').prop('checked')) {
otherPrices.hide();
minPrice1.hide();
} else {
otherPrices.show();
minPrice1.show();
}
};
jQuery(document).ready(function () {
showHidePriceRules();
jQuery('input#usePriceRules').click(showHidePriceRules);
});
</script>
<?php
if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL))
{
print $langs->trans('UseMultipriceRules'). ' <input type="checkbox" id="usePriceRules" name="usePriceRules" '.($object->price_autogen ? 'checked' : '').'><br><br>';
}
for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
{
if ($i > 1) print '<br>';
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
if ($i > 1) print '<br>';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="update_price">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
@ -905,7 +935,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
print '<table class="border" width="100%">';
// VAT
if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL))
if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // This option is kept for backward compatibility but has no sense
{
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
print $form->load_tva("tva_tx_" . $i, $object->multiprices_tva_tx["$i"], $mysoc, '', $object->id);

View File

@ -224,11 +224,11 @@ if ($PAYPALTOKEN)
$ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
$ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
echo "DoExpressCheckoutPayment API call failed.<br>\n";
echo "Detailed Error Message: " . $ErrorLongMsg."<br>\n";
echo "Short Error Message: " . $ErrorShortMsg."<br>\n";
echo "Error Code: " . $ErrorCode."<br>\n";
echo "Error Severity Code: " . $ErrorSeverityCode."<br>\n";
echo $langs->trans('DoExpressCheckoutPaymentAPICallFailed') . "<br>\n";
echo $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."<br>\n";
echo $langs->trans('ShortErrorMessage') . ": " . $ErrorShortMsg."<br>\n";
echo $langs->trans('ErrorCode') . ": " . $ErrorCode."<br>\n";
echo $langs->trans('ErrorSeverityCode') . ": " . $ErrorSeverityCode."<br>\n";
if ($mysoc->email) echo "\nPlease, send a screenshot of this page to ".$mysoc->email."<br>\n";

View File

@ -60,7 +60,7 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
// Search thirdparty
if (! empty($conf->societe->enabled) && $user->rights->societe->lire)
{
$listofsearchfields['search_thirdparty']=array('text'=>'Thirdparty');
$listofsearchfields['search_thirdparty']=array('text'=>'ThirdParty');
}
// Search contact/address
if (! empty($conf->societe->enabled) && $user->rights->societe->lire)

View File

@ -641,7 +641,7 @@ div.divphotoref {
div.statusref {
float: right;
padding-right: 12px;
margin-top: 6px;
margin-top: 7px;
margin-bottom: 10px;
}
img.photoref {

View File

@ -165,7 +165,7 @@ if ($tmpval <= 360) { $colortextbackvmenu='FFFFFF'; }
else { $colortextbackvmenu='111111'; }
$tmppart=explode(',',$colorbacktitle1);
$tmpval=(! empty($tmppart[1]) ? $tmppart[1] : '')+(! empty($tmppart[2]) ? $tmppart[2] : '')+(! empty($tmppart[3]) ? $tmppart[3] : '');
if ($tmpval <= 360) { $colortexttitle='FFFFFF'; $colorshadowtitle='888888'; }
if ($tmpval <= 260) { $colortexttitle='FFFFFF'; $colorshadowtitle='888888'; }
else { $colortexttitle='111111'; $colorshadowtitle='FFFFFF'; }
$tmppart=explode(',',$colorbacktabcard1);
$tmpval=(! empty($tmppart[1]) ? $tmppart[1] : '')+(! empty($tmppart[2]) ? $tmppart[2] : '')+(! empty($tmppart[3]) ? $tmppart[3] : '');
@ -687,7 +687,7 @@ div.divphotoref {
div.statusref {
float: right;
padding-right: 12px;
margin-top: 7px;
margin-top: 8px;
margin-bottom: 10px;
}
img.photoref {

View File

@ -2,7 +2,7 @@
<?php
/**
* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -115,7 +115,8 @@ print "port=".$conf->global->LDAP_SERVER_PORT."\n";
print "login=".$conf->global->LDAP_ADMIN_DN."\n";
print "pass=".preg_replace('/./i','*',$conf->global->LDAP_ADMIN_PASS)."\n";
print "DN to extract=".$conf->global->LDAP_MEMBER_DN."\n";
print 'Filter=('.$conf->global->LDAP_KEY_MEMBERS.'=*)'."\n";
if (! empty($conf->global->LDAP_MEMBER_FILTER)) print 'Filter=('.$conf->global->LDAP_MEMBER_FILTER.')'."\n"; // Note: filter is defined into function getRecords
else print 'Filter=('.$conf->global->LDAP_KEY_MEMBERS.'=*)'."\n";
print "----- To Dolibarr database:\n";
print "type=".$conf->db->type."\n";
print "host=".$conf->db->host."\n";
@ -191,7 +192,7 @@ if ($result >= 0)
// We disable synchro Dolibarr-LDAP
$conf->global->LDAP_MEMBER_ACTIVE=0;
$ldaprecords = $ldap->getRecords('*',$conf->global->LDAP_MEMBER_DN, $conf->global->LDAP_KEY_MEMBERS, $required_fields, 0);
$ldaprecords = $ldap->getRecords('*',$conf->global->LDAP_MEMBER_DN, $conf->global->LDAP_KEY_MEMBERS, $required_fields, 'member'); // Fiter on 'member' filter param
if (is_array($ldaprecords))
{
$db->begin();

View File

@ -106,7 +106,8 @@ print "port=".$conf->global->LDAP_SERVER_PORT."\n";
print "login=".$conf->global->LDAP_ADMIN_DN."\n";
print "pass=".preg_replace('/./i','*',$conf->global->LDAP_ADMIN_PASS)."\n";
print "DN to extract=".$conf->global->LDAP_USER_DN."\n";
print 'Filter=('.$conf->global->LDAP_KEY_USERS.'=*)'."\n";
if (! empty($conf->global->LDAP_FILTER_CONNECTION)) print 'Filter=('.$conf->global->LDAP_FILTER_CONNECTION.')'."\n"; // Note: filter is defined into function getRecords
else print 'Filter=('.$conf->global->LDAP_KEY_USERS.'=*)'."\n";
print "----- To Dolibarr database:\n";
print "type=".$conf->db->type."\n";
print "host=".$conf->db->host."\n";
@ -177,7 +178,7 @@ if ($result >= 0)
// We disable synchro Dolibarr-LDAP
$conf->global->LDAP_SYNCHRO_ACTIVE=0;
$ldaprecords = $ldap->getRecords('*',$conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 0);
$ldaprecords = $ldap->getRecords('*',$conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 'user'); // Fiter on 'user' filter param
if (is_array($ldaprecords))
{
$db->begin();