Merge branch '16.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
1cbac265f4
@ -15,7 +15,6 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -37,7 +36,7 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('admin', 'oauth'));
|
||||
$langs->loadLangs(array('admin', 'oauth', 'modulebuilder'));
|
||||
|
||||
// Security check
|
||||
if (!$user->admin) {
|
||||
@ -111,7 +110,7 @@ $form = new Form($db);
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup');
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
@ -141,22 +140,16 @@ foreach ($list as $key) {
|
||||
}
|
||||
print '</select>';
|
||||
print ajax_combobox('provider');
|
||||
print ' <input type="text" name="label" value="" placeholder="'.$langs->trans("Label").'">';
|
||||
print ' <input type="text" name="label" value="" placeholder="'.$langs->trans("Label").'" pattern="^\S+$" title="'.$langs->trans("SpaceOrSpecialCharAreNotAllowed").'">';
|
||||
print ' <input type="submit" class="button small" name="add" value="'.$langs->trans("Add").'">';
|
||||
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
print '</form>';
|
||||
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
$i = 0;
|
||||
|
||||
// Define $listinsetup
|
||||
foreach ($conf->global as $key => $val) {
|
||||
@ -172,112 +165,122 @@ foreach ($conf->global as $key => $val) {
|
||||
}
|
||||
}
|
||||
|
||||
// $list is defined into oauth.lib.php to the list of supporter OAuth providers.
|
||||
foreach ($listinsetup as $key) {
|
||||
$supported = 0;
|
||||
$keyforsupportedoauth2array = $key[0]; // May be OAUTH_GOOGLE_NAME or OAUTH_GOOGLE_xxx_NAME
|
||||
$keyforsupportedoauth2array = preg_replace('/^OAUTH_/', '', $keyforsupportedoauth2array);
|
||||
$keyforsupportedoauth2array = preg_replace('/_NAME$/', '', $keyforsupportedoauth2array);
|
||||
if (preg_match('/^.*-/', $keyforsupportedoauth2array)) {
|
||||
$keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array);
|
||||
} else {
|
||||
$keyforprovider = '';
|
||||
}
|
||||
$keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array);
|
||||
$keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME';
|
||||
|
||||
if (in_array($keyforsupportedoauth2array, array_keys($supportedoauth2array))) {
|
||||
$supported = 1;
|
||||
}
|
||||
if (!$supported) {
|
||||
continue; // show only supported
|
||||
}
|
||||
if (count($listinsetup) > 0) {
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
|
||||
$i++;
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
// Api Name
|
||||
$label = $langs->trans($keyforsupportedoauth2array);
|
||||
print '<tr class="liste_titre'.($i > 1 ? ' liste_titre_add' : '').'">';
|
||||
print '<td>';
|
||||
print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"');
|
||||
if ($label == $keyforsupportedoauth2array) {
|
||||
print $supportedoauth2array[$keyforsupportedoauth2array]['name'];
|
||||
} else {
|
||||
print $label;
|
||||
}
|
||||
if ($keyforprovider) {
|
||||
print ' (<b>'.$keyforprovider.'</b>)';
|
||||
} else {
|
||||
print ' (<b>'.$langs->trans("NoName").'</b>)';
|
||||
}
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if (!empty($supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials'])) {
|
||||
print $langs->trans("OAUTH_URL_FOR_CREDENTIAL", $supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials']);
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
$i = 0;
|
||||
|
||||
if ($supported) {
|
||||
$redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php';
|
||||
print '<tr class="oddeven value">';
|
||||
print '<td>'.$langs->trans("UseTheFollowingUrlAsRedirectURI").'</td>';
|
||||
print '<td><input style="width: 80%" type"text" name="uri'.$keyforsupportedoauth2array.'" value="'.$redirect_uri.'" disabled>';
|
||||
print '</td></tr>';
|
||||
|
||||
if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') {
|
||||
print '<tr class="oddeven value">';
|
||||
print '<td>'.$langs->trans("URLOfServiceForAuthorization").'</td>';
|
||||
print '<td><input style="width: 80%" type"text" name="'.$key[3].'" value="'.getDolGlobalString($key[3]).'" >';
|
||||
print '</td></tr>';
|
||||
// $list is defined into oauth.lib.php to the list of supporter OAuth providers.
|
||||
foreach ($listinsetup as $key) {
|
||||
$supported = 0;
|
||||
$keyforsupportedoauth2array = $key[0]; // May be OAUTH_GOOGLE_NAME or OAUTH_GOOGLE_xxx_NAME
|
||||
$keyforsupportedoauth2array = preg_replace('/^OAUTH_/', '', $keyforsupportedoauth2array);
|
||||
$keyforsupportedoauth2array = preg_replace('/_NAME$/', '', $keyforsupportedoauth2array);
|
||||
if (preg_match('/^.*-/', $keyforsupportedoauth2array)) {
|
||||
$keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array);
|
||||
} else {
|
||||
$keyforprovider = '';
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven value">';
|
||||
print '<td>'.$langs->trans("UseTheFollowingUrlAsRedirectURI").'</td>';
|
||||
print '<td>'.$langs->trans("FeatureNotYetSupported").'</td>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
$keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array);
|
||||
$keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME';
|
||||
|
||||
// Api Id
|
||||
print '<tr class="oddeven value">';
|
||||
print '<td><label for="'.$key[1].'">'.$langs->trans("OAUTH_ID").'</label></td>';
|
||||
print '<td><input type="text" size="100" id="'.$key[1].'" name="'.$key[1].'" value="'.getDolGlobalString($key[1]).'">';
|
||||
print '</td></tr>';
|
||||
if (in_array($keyforsupportedoauth2array, array_keys($supportedoauth2array))) {
|
||||
$supported = 1;
|
||||
}
|
||||
if (!$supported) {
|
||||
continue; // show only supported
|
||||
}
|
||||
|
||||
// Api Secret
|
||||
print '<tr class="oddeven value">';
|
||||
print '<td><label for="'.$key[2].'">'.$langs->trans("OAUTH_SECRET").'</label></td>';
|
||||
print '<td><input type="password" size="100" id="'.$key[2].'" name="'.$key[2].'" value="'.getDolGlobalString($key[2]).'">';
|
||||
print '</td></tr>';
|
||||
$i++;
|
||||
|
||||
// TODO Move this into token generation
|
||||
if ($supported) {
|
||||
if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') {
|
||||
// Api Name
|
||||
$label = $langs->trans($keyforsupportedoauth2array);
|
||||
print '<tr class="liste_titre'.($i > 1 ? ' liste_titre_add' : '').'">';
|
||||
print '<td>';
|
||||
print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"');
|
||||
if ($label == $keyforsupportedoauth2array) {
|
||||
print $supportedoauth2array[$keyforsupportedoauth2array]['name'];
|
||||
} else {
|
||||
print $label;
|
||||
}
|
||||
if ($keyforprovider) {
|
||||
print ' (<b>'.$keyforprovider.'</b>)';
|
||||
} else {
|
||||
print ' (<b>'.$langs->trans("NoName").'</b>)';
|
||||
}
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if (!empty($supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials'])) {
|
||||
print $langs->trans("OAUTH_URL_FOR_CREDENTIAL", $supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials']);
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
if ($supported) {
|
||||
$redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php';
|
||||
print '<tr class="oddeven value">';
|
||||
print '<td>'.$langs->trans("Scopes").'</td>';
|
||||
print '<td>';
|
||||
print '<input style="width: 80%" type"text" name="'.$key[4].'" value="'.getDolGlobalString($key[4]).'" >';
|
||||
print '<td>'.$langs->trans("UseTheFollowingUrlAsRedirectURI").'</td>';
|
||||
print '<td><input style="width: 80%" type"text" name="uri'.$keyforsupportedoauth2array.'" value="'.$redirect_uri.'" disabled>';
|
||||
print '</td></tr>';
|
||||
|
||||
if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') {
|
||||
print '<tr class="oddeven value">';
|
||||
print '<td>'.$langs->trans("URLOfServiceForAuthorization").'</td>';
|
||||
print '<td><input style="width: 80%" type"text" name="'.$key[3].'" value="'.getDolGlobalString($key[3]).'" >';
|
||||
print '</td></tr>';
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven value">';
|
||||
print '<td>'.$langs->trans("Scopes").'</td>';
|
||||
print '<td>';
|
||||
//print '<input style="width: 80%" type"text" name="'.$key[4].'" value="'.getDolGlobalString($key[4]).'" >';
|
||||
print $supportedoauth2array[$keyforsupportedoauth2array]['defaultscope'];
|
||||
print '<td>'.$langs->trans("UseTheFollowingUrlAsRedirectURI").'</td>';
|
||||
print '<td>'.$langs->trans("FeatureNotYetSupported").'</td>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Api Id
|
||||
print '<tr class="oddeven value">';
|
||||
print '<td><label for="'.$key[1].'">'.$langs->trans("OAUTH_ID").'</label></td>';
|
||||
print '<td><input type="text" size="100" id="'.$key[1].'" name="'.$key[1].'" value="'.getDolGlobalString($key[1]).'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Api Secret
|
||||
print '<tr class="oddeven value">';
|
||||
print '<td><label for="'.$key[2].'">'.$langs->trans("OAUTH_SECRET").'</label></td>';
|
||||
print '<td><input type="password" size="100" id="'.$key[2].'" name="'.$key[2].'" value="'.getDolGlobalString($key[2]).'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// TODO Move this into token generation
|
||||
if ($supported) {
|
||||
if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') {
|
||||
print '<tr class="oddeven value">';
|
||||
print '<td>'.$langs->trans("Scopes").'</td>';
|
||||
print '<td>';
|
||||
print '<input style="width: 80%" type"text" name="'.$key[4].'" value="'.getDolGlobalString($key[4]).'" >';
|
||||
print '</td></tr>';
|
||||
} else {
|
||||
print '<tr class="oddeven value">';
|
||||
print '<td>'.$langs->trans("Scopes").'</td>';
|
||||
print '<td>';
|
||||
//print '<input style="width: 80%" type"text" name="'.$key[4].'" value="'.getDolGlobalString($key[4]).'" >';
|
||||
print $supportedoauth2array[$keyforsupportedoauth2array]['defaultscope'];
|
||||
print '</td></tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</table>'."\n";
|
||||
print '</div>';
|
||||
|
||||
print $form->buttonsSaveCancel("Modify", '');
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
print '</table>'."\n";
|
||||
print '</div>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
print $form->buttonsSaveCancel("Modify", '');
|
||||
|
||||
print '</form>';
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
@ -42,8 +42,12 @@ function printDropdownBookmarksList()
|
||||
if (!empty($_SERVER["QUERY_STRING"])) {
|
||||
if (is_array($_GET)) {
|
||||
foreach ($_GET as $key => $val) {
|
||||
if ($val != '') {
|
||||
$url_param[$key]=http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val)));
|
||||
if (is_array($val)) {
|
||||
foreach ($val as $tmpsubval) {
|
||||
$url_param[] = http_build_query(array(dol_escape_htmltag($key).'[]' => dol_escape_htmltag($tmpsubval)));
|
||||
}
|
||||
} elseif ($val != '') {
|
||||
$url_param[$key] = http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -61,10 +65,11 @@ function printDropdownBookmarksList()
|
||||
if ((preg_match('/^search_/', $key) || in_array($key, $authorized_var))
|
||||
&& $val != ''
|
||||
&& !array_key_exists($key, $url_param)) {
|
||||
$url_param[$key]=http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val)));
|
||||
$url_param[$key] = http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$url .= ($tmpurl ? '?'.$tmpurl : '');
|
||||
if (!empty($url_param)) {
|
||||
$url .= '&'.implode('&', $url_param);
|
||||
|
||||
@ -124,7 +124,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes
|
||||
if ($passok) {
|
||||
$login = $obj->login;
|
||||
} else {
|
||||
sleep(2); // Anti brut force protection
|
||||
sleep(1); // Anti brut force protection
|
||||
dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO bad password for '".$usertotest."', cryptType=".$cryptType, LOG_NOTICE);
|
||||
|
||||
// Load translation files required by the page
|
||||
|
||||
@ -267,7 +267,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest)
|
||||
$ldap->ldapErrorText = ldap_error($ldap->connection);
|
||||
dol_syslog("functions_ldap::check_user_password_ldap ".$ldap->ldapErrorCode." ".$ldap->ldapErrorText);
|
||||
}
|
||||
sleep(2); // Anti brut force protection
|
||||
sleep(1); // Anti brut force protection
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('main', 'other', 'errors'));
|
||||
|
||||
@ -101,7 +101,7 @@ if (empty($reshook) && isset($extrafields->attributes[$object->table_element]['l
|
||||
if ($action == 'edit_extras') {
|
||||
$value = (GETPOSTISSET("options_".$tmpkeyextra) ? GETPOST("options_".$tmpkeyextra) : $object->array_options["options_".$tmpkeyextra]);
|
||||
} else {
|
||||
$value = (!empty($object->array_options["options_".$tmpkeyextra]) ? $object->array_options["options_".$tmpkeyextra] : '');
|
||||
$value = (isset($object->array_options["options_".$tmpkeyextra]) ? $object->array_options["options_".$tmpkeyextra] : '');
|
||||
//var_dump($tmpkeyextra.' - '.$value);
|
||||
}
|
||||
|
||||
|
||||
@ -44,8 +44,6 @@ $result = restrictedArea($user, 'societe', '', '');
|
||||
$result = restrictedArea($user, 'margins');
|
||||
|
||||
|
||||
$mesg = '';
|
||||
|
||||
// Load variable for pagination
|
||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
@ -65,18 +63,18 @@ if (!$sortorder) {
|
||||
}
|
||||
|
||||
$startdate = $enddate = '';
|
||||
|
||||
if (!empty($_POST['startdatemonth'])) {
|
||||
$startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']);
|
||||
if (GETPOST('startdatemonth')) {
|
||||
$startdate = dol_mktime(0, 0, 0, GETPOST('startdatemonth', 'int'), GETPOST('startdateday', 'int'), GETPOST('startdateyear', 'int'));
|
||||
}
|
||||
if (!empty($_POST['enddatemonth'])) {
|
||||
$enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']);
|
||||
if (GETPOST('enddatemonth')) {
|
||||
$enddate = dol_mktime(23, 59, 59, GETPOST('enddatemonth', 'int'), GETPOST('enddateday', 'int'), GETPOST('enddateyear'));
|
||||
}
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$object = new Societe($db);
|
||||
$hookmanager->initHooks(array('margincustomerlist'));
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
@ -189,7 +187,7 @@ print '<table class="border centpercent">';
|
||||
|
||||
// Total Margin
|
||||
print '<tr><td class="titlefield">'.$langs->trans("TotalMargin").'</td><td colspan="4">';
|
||||
print '<span id="totalMargin"></span>'; // set by jquery (see below)
|
||||
print '<span id="totalMargin" class="amount"></span> <span class="amount">'.$langs->getCurrencySymbol($conf->currency).'</span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
|
||||
// Margin Rate
|
||||
@ -272,6 +270,30 @@ $sql .= $db->order($sortfield, $sortorder);
|
||||
// TODO: calculate total to display then restore pagination
|
||||
//$sql.= $db->plimit($conf->liste_limit +1, $offset);
|
||||
|
||||
$param = '&socid='.((int) $socid);
|
||||
if (GETPOST('startdatemonth', 'int')) {
|
||||
$param .= '&startdateyear='.GETPOST('startdateyear', 'int');
|
||||
$param .= '&startdatemonth='.GETPOST('startdatemonth', 'int');
|
||||
$param .= '&startdateday='.GETPOST('startdateday', 'int');
|
||||
}
|
||||
if (GETPOST('enddatemonth', 'int')) {
|
||||
$param .= '&enddateyear='.GETPOST('enddateyear', 'int');
|
||||
$param .= '&enddatemonth='.GETPOST('enddatemonth', 'int');
|
||||
$param .= '&enddateday='.GETPOST('enddateday', 'int');
|
||||
}
|
||||
$listofproducts = GETPOST('products', 'array:int');
|
||||
if (is_array($listofproducts)) {
|
||||
foreach ($listofproducts as $val) {
|
||||
$param .= '&products[]='.$val;
|
||||
}
|
||||
}
|
||||
$listofcateg = GETPOST('categories', 'array:int');
|
||||
if (is_array($listofcateg)) {
|
||||
foreach ($listofcateg as $val) {
|
||||
$param .= '&categories[]='.$val;
|
||||
}
|
||||
}
|
||||
|
||||
dol_syslog('margin::customerMargins.php', LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
@ -294,19 +316,19 @@ if ($result) {
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
if (!empty($client)) {
|
||||
print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&socid=".$socid, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&socid=".$socid, 'align="center"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
} else {
|
||||
print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", "&socid=".$socid, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, 'align="right"', $sortfield, $sortorder);
|
||||
if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder);
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
@ -74,18 +74,18 @@ if (!$sortfield) {
|
||||
}
|
||||
|
||||
$startdate = $enddate = '';
|
||||
|
||||
if (!empty($_POST['startdatemonth'])) {
|
||||
$startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']);
|
||||
if (GETPOST('startdatemonth')) {
|
||||
$startdate = dol_mktime(0, 0, 0, GETPOST('startdatemonth', 'int'), GETPOST('startdateday', 'int'), GETPOST('startdateyear', 'int'));
|
||||
}
|
||||
if (!empty($_POST['enddatemonth'])) {
|
||||
$enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']);
|
||||
if (GETPOST('enddatemonth')) {
|
||||
$enddate = dol_mktime(23, 59, 59, GETPOST('enddatemonth', 'int'), GETPOST('enddateday', 'int'), GETPOST('enddateyear'));
|
||||
}
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$object = new Product($db);
|
||||
$hookmanager->initHooks(array('marginproductlist'));
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
@ -150,7 +150,7 @@ print '<table class="border centpercent">';
|
||||
|
||||
// Total Margin
|
||||
print '<tr><td class="titlefield">'.$langs->trans("TotalMargin").'</td><td colspan="4">';
|
||||
print '<span id="totalMargin"></span>'; // set by jquery (see below)
|
||||
print '<span id="totalMargin" class="amount"></span> <span class="amount">'.$langs->getCurrencySymbol($conf->currency).'</span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
|
||||
// Margin Rate
|
||||
@ -225,13 +225,31 @@ $sql .= $db->order($sortfield, $sortorder);
|
||||
// TODO: calculate total to display then restore pagination
|
||||
//$sql.= $db->plimit($conf->liste_limit +1, $offset);
|
||||
|
||||
$param = '&id='.((int) $id);
|
||||
if (GETPOST('startdatemonth', 'int')) {
|
||||
$param .= '&startdateyear='.GETPOST('startdateyear', 'int');
|
||||
$param .= '&startdatemonth='.GETPOST('startdatemonth', 'int');
|
||||
$param .= '&startdateday='.GETPOST('startdateday', 'int');
|
||||
}
|
||||
if (GETPOST('enddatemonth', 'int')) {
|
||||
$param .= '&enddateyear='.GETPOST('enddateyear', 'int');
|
||||
$param .= '&enddatemonth='.GETPOST('enddatemonth', 'int');
|
||||
$param .= '&enddateday='.GETPOST('enddateday', 'int');
|
||||
}
|
||||
$listofcateg = GETPOST('categories', 'array:int');
|
||||
if (is_array($listofcateg)) {
|
||||
foreach ($listofcateg as $val) {
|
||||
$param .= '&categories[]='.$val;
|
||||
}
|
||||
}
|
||||
|
||||
dol_syslog('margin::productMargins.php', LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
print '<br>';
|
||||
print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "&id=".$id, $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1);
|
||||
print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1);
|
||||
|
||||
//var_dump($conf->global->MARGIN_TYPE);
|
||||
if ($conf->global->MARGIN_TYPE == "1") {
|
||||
@ -248,20 +266,20 @@ if ($result) {
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
if ($id > 0) {
|
||||
print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&id=".$id, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&id=".$id, '', $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
} else {
|
||||
print_liste_field_titre("ProductService", $_SERVER["PHP_SELF"], "p.ref", "", "&id=".$id, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("ProductService", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "product_qty", "", "&id=".$id, '', $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", "&id=".$id, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", "&id=".$id, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&id=".$id, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "product_qty", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&id=".$id, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
}
|
||||
if (!empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&id=".$id, '', $sortfield, $sortorder, 'right ');
|
||||
print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user