Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Allow to set a default project for POS sales #27042

Merged
merged 4 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions htdocs/langs/en_US/admin.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1881,6 +1881,7 @@ CashDeskYouDidNotDisableStockDecease=You did not disable stock decrease when mak
CashDeskForceDecreaseStockLabel=Stock decrease for batch products was forced.
CashDeskForceDecreaseStockDesc=Decrease first by the oldest eatby and sellby dates.
CashDeskReaderKeyCodeForEnter=Key ASCII code for "Enter" defined in barcode reader (Example: 13)
CashDeskDefaultProject=Assign all future sales to this project
##### Bookmark #####
BookmarkSetup=Bookmark module setup
BookmarkDesc=This module allows you to manage bookmarks. You can also add shortcuts to any Dolibarr pages or external web sites on your left menu.
Expand Down
13 changes: 12 additions & 1 deletion htdocs/takepos/admin/terminal.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
$res = dolibarr_set_const($db, "TAKEPOS_TERMINAL_NAME_".$terminaltouse, (!empty(GETPOST('terminalname'.$terminaltouse, 'restricthtml')) ? GETPOST('terminalname'.$terminaltouse, 'restricthtml') : $langs->trans("TerminalName", $terminaltouse)), 'chaine', 0, '', $conf->entity);

$res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY".$terminaltouse, (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity);

$res = dolibarr_set_const($db, "CASHDESK_ID_PROJECT".$terminaltouse, (GETPOST('projectid', 'int') > 0 ? GETPOST('projectid', 'int') : ''), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CHEQUE".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CB".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
Expand Down Expand Up @@ -157,6 +157,17 @@
print '<input type="text" name="terminalname'.$terminal.'" value="'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$terminal, $langs->trans("TerminalName", $terminal)).'" >';
print '</td></tr>';

if (isModEnabled('project')) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
$formproject = new FormProjets($db);
print '<tr class="oddeven"><td>'.$langs->trans("CashDeskDefaultProject").'</td><td>';
print img_picto('', 'project', 'class="pictofixedwidth"');
// select_projects($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 16, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $morecss = '', $htmlid = '', $morefilter = '')
$projectid = getDolGlobalInt('CASHDESK_ID_PROJECT'.$terminaltouse);
print $formproject->select_projects(-1, $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 1, 'maxwidth500 widthcentpercentminusxx');
print '</td></tr>';
}

print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
print '<td>';
print img_picto('', 'company', 'class="pictofixedwidth"');
Expand Down
10 changes: 8 additions & 2 deletions htdocs/takepos/invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
}
}

$takeposterminal = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '';

/**
* Abort invoice creation with a given error message
Expand Down Expand Up @@ -135,13 +136,13 @@ function fail($message)
if ($invoiceid > 0) {
$ret = $invoice->fetch($invoiceid);
} else {
$ret = $invoice->fetch('', '(PROV-POS'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '') .'-'.$place.')');
$ret = $invoice->fetch('', '(PROV-POS'.$takeposterminal.'-'.$place.')');
}
if ($ret > 0) {
$placeid = $invoice->id;
}

$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'. (isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '');
$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$takeposterminal;

$soc = new Societe($db);
if ($invoice->socid > 0) {
Expand All @@ -150,6 +151,11 @@ function fail($message)
$soc->fetch(getDolGlobalString($constforcompanyid));
}

// Assign a default project, if relevant
if (isModEnabled('project') && getDolGlobalInt("CASHDESK_ID_PROJECT".$takeposterminal)) {
$invoice->fk_project = getDolGlobalInt("CASHDESK_ID_PROJECT".$takeposterminal);
}

// Change the currency of invoice if it was modified
if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency"])) {
if ($invoice->multicurrency_code != $_SESSION["takeposcustomercurrency"]) {
Expand Down