Merge branch 'develop' into membership-rework

This commit is contained in:
Laurent Destailleur 2022-07-10 18:58:49 +02:00 committed by GitHub
commit 16d04e475b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
99 changed files with 1571 additions and 278 deletions

View File

@ -125,6 +125,7 @@ NEW: VAT Report by month - Show detail by rate and also by code
NEW: Ticket triggers: allow to automatically send messages on new tickets
NEW: Accountancy - Add hidden feature for accounting reconciliation
NEW: Can store the session into database (instead of beeing managed by PHP)
NEW: Added MMK currency (Myanmar Kyat)
Modules
NEW: Module Partnership Management

View File

@ -220,7 +220,7 @@ llxheader('', $title, $help_url);
// Create mode
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans('NewAccountingAccount'));
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";

View File

@ -154,7 +154,7 @@ $help_url = "EN:Module_Double_Entry_Accounting";
llxHeader('', $title, $help_url);
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewFiscalYear"));
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';

View File

@ -340,7 +340,7 @@ if ($action == 'delete') {
print $formconfirm;
}
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("CreateMvts"));
$object = new BookKeeping($db);

View File

@ -920,7 +920,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// -----------------------------------------
// Create mode
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
$object->canvas = $canvas;
$object->state_id = GETPOST('state_id', 'int');

View File

@ -253,7 +253,7 @@ $help_url = "EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électro
llxHeader('', 'EmailCollector', $help_url);
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewEmailCollector", $langs->transnoentitiesnoconv("EmailCollector")));
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -197,8 +197,25 @@ print '</div>';
print '</td>';
print '<td class="tdtop">';
print '<button id="btn" type="button" onclick="hideoptions()">'.$langs->trans("ShowAdvancedOptions").'</button>';
print '<div id="div_container_sub_exportoptions">';
print '<script type="text/javascript">
function hideoptions(){
const btn = document.getElementById("btn");
const div = document.getElementById("div_container_sub_exportoptions");
if (div.style.display === "none") {
div.style.display = "block";
btn.innerText="'.$langs->trans("HideAdvancedoptions").'";
} else {
div.style.display = "none";
btn.innerText="'.$langs->trans("ShowAdvancedOptions").'";
}
}
</script>';
print '<div id="div_container_sub_exportoptions" style="display: none;">';
if (in_array($type, array('mysql', 'mysqli'))) {
print "<!-- Fieldset mysqldump -->\n";
print '<fieldset id="mysql_options"><legend>'.$langs->trans("MySqlExportParameters").'</legend>';

View File

@ -166,7 +166,7 @@ $help_url = '';
llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Asset")), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -138,7 +138,7 @@ $help_url = '';
llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("AssetModel")), '', 'object_' . $object->picto);
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';

View File

@ -268,7 +268,7 @@ $help_url ='EN:Module_BOM';
llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewBOM"), '', 'bom');
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -144,7 +144,7 @@ $h++;
$hselected = 'card';
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
/*
* Fact bookmark creation mode
*/

View File

@ -923,7 +923,7 @@ $arrayrecurrulefreq = array(
$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
llxHeader('', $langs->trans("Agenda"), $help_url);
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
$contact = new Contact($db);
$socpeopleassigned = GETPOST("socpeopleassigned", 'array');

View File

@ -1121,7 +1121,8 @@ if ($object->id > 0) {
* Latest contracts
*/
if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) {
$sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut as contract_status, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup, c.entity";
$sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut as contract_status, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup, c.entity,";
$sql .= " c.last_main_doc, c.model_pdf";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
$sql .= " WHERE c.fk_soc = s.rowid ";
$sql .= " AND s.rowid = ".((int) $object->id);
@ -1154,6 +1155,8 @@ if ($object->id > 0) {
$contrat->ref_customer = $objp->refcus;
$contrat->ref_supplier = $objp->refsup;
$contrat->statut = $objp->contract_status;
$contrat->last_main_doc = $objp->last_main_doc;
$contrat->model_pdf = $objp->model_pdf;
$contrat->fetch_lines();
$late = '';
@ -1168,30 +1171,32 @@ if ($object->id > 0) {
print '<tr class="oddeven">';
print '<td class="nowraponall">';
print $contrat->getNomUrl(1, 12);
// Preview
$filedir = $conf->contrat->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
$file_list = null;
if (!empty($filedir)) {
$file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
}
if (is_array($file_list)) {
// Defined relative dir to DOL_DATA_ROOT
$relativedir = '';
if ($filedir) {
$relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
$relativedir = preg_replace('/^[\\/]/', '', $relativedir);
if (!empty($contrat->model_pdf)) {
// Preview
$filedir = $conf->contrat->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
$file_list = null;
if (!empty($filedir)) {
$file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
}
// Get list of files stored into database for same relative directory
if ($relativedir) {
completeFileArrayWithDatabaseInfo($file_list, $relativedir);
//var_dump($sortfield.' - '.$sortorder);
if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
$file_list = dol_sort_array($file_list, $sortfield, $sortorder);
if (is_array($file_list)) {
// Defined relative dir to DOL_DATA_ROOT
$relativedir = '';
if ($filedir) {
$relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
$relativedir = preg_replace('/^[\\/]/', '', $relativedir);
}
// Get list of files stored into database for same relative directory
if ($relativedir) {
completeFileArrayWithDatabaseInfo($file_list, $relativedir);
//var_dump($sortfield.' - '.$sortorder);
if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
$file_list = dol_sort_array($file_list, $sortfield, $sortorder);
}
}
$relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
print $formfile->showPreview($file_list, $contrat->element, $relativepath, 0);
}
$relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
print $formfile->showPreview($file_list, $contrat->element, $relativepath, 0);
}
// $filename = dol_sanitizeFileName($objp->ref);
// $filedir = $conf->contrat->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);

View File

@ -127,6 +127,7 @@ if ($tmp) {
/*
* Draft customer proposals
*/
if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
$sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
$sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
@ -224,6 +225,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
/*
* Draft supplier proposals
*/
if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) {
$sql = "SELECT p.rowid, p.ref, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
$sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
@ -320,6 +322,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa
/*
* Draft customer orders
*/
if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
$sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.total_tva, c.total_ttc, c.fk_statut as status";
$sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
@ -404,7 +407,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
}
}
addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
addSummaryTableLine(3, $num, $nbofloop, $total, "NoOrder");
finishSimpleTable(true);
$db->free($resql);
@ -417,6 +420,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
/*
* Draft purchase orders
*/
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire)) {
$sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_statut as status";
$sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
@ -501,7 +505,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
}
}
addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
addSummaryTableLine(3, $num, $nbofloop, $total, "NoOrder");
finishSimpleTable(true);
$db->free($resql);

View File

@ -704,7 +704,7 @@ llxHeader(
array()
);
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
// EMailing in creation mode
print '<form name="new_mailing" action="'.$_SERVER['PHP_SELF'].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">';

View File

@ -1537,7 +1537,7 @@ llxHeader('', $title, $help_url);
$now = dol_now();
// Add new proposal
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
$currency_code = $conf->currency;
print load_fiche_titre($langs->trans("NewProp"), '', 'propal');

View File

@ -336,7 +336,7 @@ $help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Ba
// Creation
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
$object = new Account($db);
$title = $langs->trans("NewFinancialAccount");

View File

@ -339,7 +339,7 @@ foreach ($bankcateg->fetchAll() as $bankcategory) {
}
// Create mode
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
// Update fields properties in realtime
if (!empty($conf->use_javascript_ajax)) {
print "\n".'<script type="text/javascript">';

View File

@ -194,7 +194,7 @@ $form = new Form($db);
/*
* Action create
*/
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
//WYSIWYG Editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -2890,7 +2890,7 @@ llxHeader('', $title, $help_url);
// Mode creation
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
$facturestatic = new Facture($db);
$extrafields->fetch_name_optionals_label($facturestatic->table_element);

View File

@ -3140,6 +3140,7 @@ class Facture extends CommonInvoice
} else {
$num = $this->ref;
}
$this->newref = dol_sanitizeFileName($num);
if ($num) {
@ -3147,7 +3148,7 @@ class Facture extends CommonInvoice
// Validate
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql .= " SET ref='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".($user->id > 0 ? $user->id : "null").", date_valid = '".$this->db->idate($now)."'";
$sql .= " SET ref = '".$this->db->escape($num)."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".($user->id > 0 ? $user->id : "null").", date_valid = '".$this->db->idate($now)."'";
if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) { // If option enabled, we force invoice date
$sql .= ", datef='".$this->db->idate($this->date)."'";
$sql .= ", date_lim_reglement='".$this->db->idate($this->date_lim_reglement)."'";
@ -3819,6 +3820,7 @@ class Facture extends CommonInvoice
return -2;
}
} else {
$this->errors[]='status of invoice must be Draft to allow use of ->addline()';
dol_syslog(get_class($this)."::addline status of invoice must be Draft to allow use of ->addline()", LOG_ERR);
return -3;
}
@ -4383,7 +4385,6 @@ class Facture extends CommonInvoice
$mybool = false;
$file = $addon.'.php';
$classname = $addon;
@ -4421,8 +4422,10 @@ class Facture extends CommonInvoice
}
$obj = new $classname();
$numref = $obj->getNextValue($soc, $this, $mode);
/**
* $numref can be empty in case we ask for the last value because if there is no invoice created with the
* set up mask.
@ -5449,8 +5452,6 @@ class Facture extends CommonInvoice
dol_syslog(__METHOD__, LOG_DEBUG);
$this->db->begin();
// Select all action comm reminder
$sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."facture as f";
if (!empty($paymentmode) && $paymentmode != 'all') {
@ -5539,20 +5540,92 @@ class Facture extends CommonInvoice
}
if (!$error && $to) {
$this->db->begin();
// Errors Recipient
$errors_to = $conf->global->MAIN_MAIL_ERRORS_TO;
$trackid = 'inv'.$tmpinvoice->id;
$sendcontext = 'standard';
// Mail Creation
$cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', $trackid, '', '', '');
$cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', $trackid, '', $sendcontext, '');
// Sending Mail
if ($cMailFile->sendfile()) {
$nbMailSend++;
// Add a line into event table
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
// Insert record of emails sent
$actioncomm = new ActionComm($this->db);
$actioncomm->type_code = 'AC_OTH_AUTO'; // Event insert into agenda automatically
$actioncomm->socid = $tmpinvoice->thirdparty->id; // To link to a company
$actioncomm->contact_id = 0;
$actioncomm->code = 'AC_EMAIL';
$actioncomm->label = 'sendEmailsRemindersOnInvoiceDueDateOK';
$actioncomm->note_private = $sendContent;
$actioncomm->fk_project = $tmpinvoice->fk_project;
$actioncomm->datep = dol_now();
$actioncomm->datef = $actioncomm->datep;
$actioncomm->percentage = -1; // Not applicable
$actioncomm->authorid = $user->id; // User saving action
$actioncomm->userownerid = $user->id; // Owner of action
// Fields when action is an email (content should be added into note)
$actioncomm->email_msgid = $cMailFile->msgid;
$actioncomm->email_from = $from;
$actioncomm->email_sender = '';
$actioncomm->email_to = $to;
//$actioncomm->email_tocc = $sendtocc;
//$actioncomm->email_tobcc = $sendtobcc;
//$actioncomm->email_subject = $subject;
$actioncomm->errors_to = $errors_to;
//$actioncomm->extraparams = $extraparams;
$actioncomm->create($user);
} else {
$errormesg = $cMailFile->error.' : '.$to;
$error++;
// Add a line into event table
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
// Insert record of emails sent
$actioncomm = new ActionComm($this->db);
$actioncomm->type_code = 'AC_OTH_AUTO'; // Event insert into agenda automatically
$actioncomm->socid = $tmpinvoice->thirdparty->id; // To link to a company
$actioncomm->contact_id = 0;
$actioncomm->code = 'AC_EMAIL';
$actioncomm->label = 'sendEmailsRemindersOnInvoiceDueDateKO';
$actioncomm->note_private = $errormesg;
$actioncomm->fk_project = $tmpinvoice->fk_project;
$actioncomm->datep = dol_now();
$actioncomm->datef = $actioncomm->datep;
$actioncomm->percentage = -1; // Not applicable
$actioncomm->authorid = $user->id; // User saving action
$actioncomm->userownerid = $user->id; // Owner of action
// Fields when action is an email (content should be added into note)
$actioncomm->email_msgid = $cMailFile->msgid;
$actioncomm->email_from = $from;
$actioncomm->email_sender = '';
$actioncomm->email_to = $to;
//$actioncomm->email_tocc = $sendtocc;
//$actioncomm->email_tobcc = $sendtobcc;
//$actioncomm->email_subject = $subject;
$actioncomm->errors_to = $errors_to;
//$actioncomm->extraparams = $extraparams;
$actioncomm->create($user);
}
$this->db->commit(); // We always commit
}
if ($errormesg) {
@ -5570,10 +5643,8 @@ class Facture extends CommonInvoice
if (!$error) {
$this->output .= 'Nb of emails sent : '.$nbMailSend;
$this->db->commit();
return 0;
} else {
$this->db->commit(); // We commit also on error, to have the error message recorded.
$this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error;
return $error;
}
@ -5581,8 +5652,9 @@ class Facture extends CommonInvoice
/**
* See if current invoice date is posterior to the last invoice date among validated invoices of same type.
*
* @param boolean $allow_validated_drafts return true if the invoice has been validated before returning to DRAFT state.
* @return boolean
* @return array return array
*/
public function willBeLastOfSameType($allow_validated_drafts = false)
{
@ -5606,10 +5678,10 @@ class Facture extends CommonInvoice
$is_last_of_same_type = $is_last_of_same_type || (!strpos($this->ref, 'PROV') && $this->status == self::STATUS_DRAFT);
}
return [$is_last_of_same_type, $last_date];
return array($is_last_of_same_type, $last_date);
} else {
// element is first of type to be validated
return [true];
return array(true);
}
} else {
dol_print_error($this->db);

View File

@ -145,7 +145,7 @@ $title = $langs->trans("LT".$object->ltt)." - ".$langs->trans("Card");
$help_url = '';
llxHeader('', $title, $helpurl);
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code));
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" name="formlocaltax" method="post">'."\n";

View File

@ -343,7 +343,7 @@ llxHeader("", $title, $help_url);
// Form to create a social contribution
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewSocialContribution"));
print '<form name="charge" method="post" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -398,7 +398,7 @@ if ($id) {
}
// Form to enter VAT
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("VAT").' - '.$langs->trans("New"));
if (!empty($conf->use_javascript_ajax)) {

View File

@ -572,7 +572,6 @@ if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $c
$title = $object->lastname;
}
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
@ -623,11 +622,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Show tabs
$head = contact_prepare_head($object);
$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
llxHeader('', $title, $help_url);
}
if ($user->rights->societe->contact->creer) {
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
/*
* Fiche en mode creation
*/
@ -643,8 +642,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$object->country = $tmparray['label'];
}
$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress"));
$linkback = '';
$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress"));
llxHeader('', $title, $help_url);
print load_fiche_titre($title, $linkback, 'address');
// Show errors

View File

@ -582,7 +582,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && (
}
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Empresas';
llxHeader('', $title, $help_url);
llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist');
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {

View File

@ -1017,7 +1017,7 @@ if ($result > 0) {
}
// Create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans('AddContract'), '', 'contract');
$soc = new Societe($db);

View File

@ -70,7 +70,10 @@ $productstatic = new Product($db);
$now = dol_now();
llxHeader();
$title = $langs->trans("ContractsArea");
$help_url = '';
llxHeader('', $title, $help_url);
print load_fiche_titre($langs->trans("ContractsArea"), '', 'contract');

View File

@ -669,6 +669,7 @@ if (!$error && $massaction == 'confirm_presend') {
}
}
if (!$error && $massaction == 'cancelorders') {
$db->begin();

View File

@ -774,6 +774,11 @@ class Conf
$this->global->MULTICURRENCY_USE_ORIGIN_TX = 1;
}
// By default, use an enclosure " for field with CRL or LF into content, + we also remove also CRL/LF chars.
if (!isset($this->global->USE_STRICT_CSV_RULES)) {
$this->global->USE_STRICT_CSV_RULES = 2;
}
// Use a SCA ready workflow with Stripe module (STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION by default if nothing defined)
if (!isset($this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) && empty($this->global->STRIPE_USE_NEW_CHECKOUT)) {
$this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 1;

View File

@ -105,6 +105,7 @@ class ExtraFields
'phone'=>'ExtrafieldPhone',
'mail'=>'ExtrafieldMail',
'url'=>'ExtrafieldUrl',
'ip'=>'ExtrafieldIP',
'password' => 'ExtrafieldPassword',
'select' => 'ExtrafieldSelect',
'sellist' => 'ExtrafieldSelectList',
@ -156,9 +157,10 @@ class ExtraFields
* @param string $enabled Condition to have the field enabled or not
* @param int $totalizable Is a measure. Must show a total on lists
* @param int $printable Is extrafield displayed on PDF
* @param array $moreparams More parameters. Example: array('css'=>, 'csslist'=>Css on list, 'cssview'=>...)
* @return int <=0 if KO, >0 if OK
*/
public function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value = '', $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0)
public function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value = '', $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0, $moreparams = array())
{
if (empty($attrname)) {
return -1;
@ -182,12 +184,12 @@ class ExtraFields
// Create field into database except for separator type which is not stored in database
if ($type != 'separate') {
$result = $this->create($attrname, $type, $size, $elementtype, $unique, $required, $default_value, $param, $perms, $list, $computed, $help);
$result = $this->create($attrname, $type, $size, $elementtype, $unique, $required, $default_value, $param, $perms, $list, $computed, $help, $moreparams);
}
$err1 = $this->errno;
if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate') {
// Add declaration of field into table
$result2 = $this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $help, $default_value, $computed, $entity, $langfile, $enabled, $totalizable, $printable);
$result2 = $this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $help, $default_value, $computed, $entity, $langfile, $enabled, $totalizable, $printable, $moreparams);
$err2 = $this->errno;
if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS')) {
$this->error = '';
@ -217,9 +219,10 @@ class ExtraFields
* @param string $list Into list view by default
* @param string $computed Computed value
* @param string $help Help on tooltip
* @param array $moreparams More parameters. Example: array('css'=>, 'csslist'=>, 'cssview'=>...)
* @return int <=0 if KO, >0 if OK
*/
private function create($attrname, $type = 'varchar', $length = 255, $elementtype = 'member', $unique = 0, $required = 0, $default_value = '', $param = '', $perms = '', $list = '0', $computed = '', $help = '')
private function create($attrname, $type = 'varchar', $length = 255, $elementtype = 'member', $unique = 0, $required = 0, $default_value = '', $param = '', $perms = '', $list = '0', $computed = '', $help = '', $moreparams = array())
{
if ($elementtype == 'thirdparty') {
$elementtype = 'societe';
@ -243,7 +246,7 @@ class ExtraFields
} elseif ($type == 'phone') {
$typedb = 'varchar';
$lengthdb = '20';
} elseif ($type == 'mail') {
} elseif ($type == 'mail' || $type == 'ip') {
$typedb = 'varchar';
$lengthdb = '128';
} elseif ($type == 'url') {
@ -315,11 +318,12 @@ class ExtraFields
* @param string $langfile Language file
* @param string $enabled Condition to have the field enabled or not
* @param int $totalizable Is a measure. Must show a total on lists
* @param int $printable Is extrafield displayed on PDF
* @param int $printable Is extrafield displayed on PDF
* @param array $moreparams More parameters. Example: array('css'=>, 'csslist'=>, 'cssview'=>...)
* @return int <=0 if KO, >0 if OK
* @throws Exception
*/
private function create_label($attrname, $label = '', $type = '', $pos = 0, $size = 0, $elementtype = 'member', $unique = 0, $required = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0)
private function create_label($attrname, $label = '', $type = '', $pos = 0, $size = 0, $elementtype = 'member', $unique = 0, $required = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0, $moreparams = array())
{
// phpcs:enable
global $conf, $user;
@ -354,6 +358,19 @@ class ExtraFields
$totalizable = 0;
}
$css = '';
if (!empty($moreparams) && !empty($moreparams['css'])) {
$css = $moreparams['css'];
}
$csslist = '';
if (!empty($moreparams) && !empty($moreparams['csslist'])) {
$csslist = $moreparams['csslist'];
}
$cssview = '';
if (!empty($moreparams) && !empty($moreparams['cssview'])) {
$cssview = $moreparams['cssview'];
}
if (!empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname) && !is_numeric($attrname)) {
if (is_array($param) && count($param) > 0) {
$params = serialize($param);
@ -386,7 +403,10 @@ class ExtraFields
$sql .= " datec,";
$sql .= " enabled,";
$sql .= " help,";
$sql .= " totalizable";
$sql .= " totalizable,";
$sql .= " css,";
$sql .= " csslist,";
$sql .= " cssview";
$sql .= " )";
$sql .= " VALUES('".$this->db->escape($attrname)."',";
$sql .= " '".$this->db->escape($label)."',";
@ -410,7 +430,10 @@ class ExtraFields
$sql .= "'".$this->db->idate(dol_now())."',";
$sql .= " ".($enabled ? "'".$this->db->escape($enabled)."'" : "1").",";
$sql .= " ".($help ? "'".$this->db->escape($help)."'" : "null").",";
$sql .= " ".($totalizable ? 'TRUE' : 'FALSE');
$sql .= " ".($totalizable ? 'TRUE' : 'FALSE').",";
$sql .= " ".($css ? "'".$this->db->escape($css)."'" : "null").",";
$sql .= " ".($csslist ? "'".$this->db->escape($csslist)."'" : "null").",";
$sql .= " ".($cssview ? "'".$this->db->escape($cssview)."'" : "null");
$sql .= ')';
dol_syslog(get_class($this)."::create_label", LOG_DEBUG);
@ -542,11 +565,12 @@ class ExtraFields
* @param string $langfile Language file
* @param string $enabled Condition to have the field enabled or not
* @param int $totalizable Is extrafield totalizable on list
* @param int $printable Is extrafield displayed on PDF
* @param int $printable Is extrafield displayed on PDF
* @param array $moreparams More parameters. Example: array('css'=>, 'csslist'=>, 'cssview'=>...)
* @return int >0 if OK, <=0 if KO
* @throws Exception
*/
public function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0)
public function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0, $moreparams = array())
{
global $hookmanager;
@ -572,7 +596,7 @@ class ExtraFields
} elseif ($type == 'phone') {
$typedb = 'varchar';
$lengthdb = '20';
} elseif ($type == 'mail') {
} elseif ($type == 'mail' || $type == 'ip') {
$typedb = 'varchar';
$lengthdb = '128';
} elseif ($type == 'url') {
@ -611,7 +635,7 @@ class ExtraFields
}
if ($result > 0 || $type == 'separate') {
if ($label) {
$result = $this->update_label($attrname, $label, $type, $length, $elementtype, $unique, $required, $pos, $param, $alwayseditable, $perms, $list, $help, $default, $computed, $entity, $langfile, $enabled, $totalizable, $printable);
$result = $this->update_label($attrname, $label, $type, $length, $elementtype, $unique, $required, $pos, $param, $alwayseditable, $perms, $list, $help, $default, $computed, $entity, $langfile, $enabled, $totalizable, $printable, $moreparams);
}
if ($result > 0) {
$sql = '';
@ -663,11 +687,12 @@ class ExtraFields
* @param string $langfile Language file
* @param string $enabled Condition to have the field enabled or not
* @param int $totalizable Is extrafield totalizable on list
* @param int $printable Is extrafield displayed on PDF
* @param int $printable Is extrafield displayed on PDF
* @param array $moreparams More parameters. Example: array('css'=>, 'csslist'=>, 'cssview'=>...)
* @return int <=0 if KO, >0 if OK
* @throws Exception
*/
private function update_label($attrname, $label, $type, $size, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '0', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0)
private function update_label($attrname, $label, $type, $size, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '0', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0, $moreparams = array())
{
// phpcs:enable
global $conf, $user;
@ -700,6 +725,19 @@ class ExtraFields
$alwayseditable = 0;
}
$css = '';
if (!empty($moreparams) && !empty($moreparams['css'])) {
$css = $moreparams['css'];
}
$csslist = '';
if (!empty($moreparams) && !empty($moreparams['csslist'])) {
$csslist = $moreparams['csslist'];
}
$cssview = '';
if (!empty($moreparams) && !empty($moreparams['cssview'])) {
$cssview = $moreparams['cssview'];
}
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname)) {
$this->db->begin();
@ -749,7 +787,10 @@ class ExtraFields
$sql .= " fk_user_modif,";
$sql .= " datec,";
$sql .= " enabled,";
$sql .= " help";
$sql .= " help,";
$sql .= " css,";
$sql .= " csslist,";
$sql .= " cssview";
$sql .= ") VALUES (";
$sql .= "'".$this->db->escape($attrname)."',";
$sql .= " ".($entity === '' ? $conf->entity : $entity).",";
@ -773,7 +814,10 @@ class ExtraFields
$sql .= " ".$user->id.",";
$sql .= "'".$this->db->idate(dol_now())."',";
$sql .= "'".$this->db->escape($enabled)."',";
$sql .= " ".($help ? "'".$this->db->escape($help)."'" : "null");
$sql .= " ".($help ? "'".$this->db->escape($help)."'" : "null").",";
$sql .= " ".($css ? "'".$this->db->escape($css)."'" : "null").",";
$sql .= " ".($csslist ? "'".$this->db->escape($csslist)."'" : "null").",";
$sql .= " ".($cssview ? "'".$this->db->escape($cssview)."'" : "null");
$sql .= ")";
$resql2 = $this->db->query($sql);
@ -952,7 +996,10 @@ class ExtraFields
}
}
//
// 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200'
if (empty($morecss)) {
// Add automatic css
if ($type == 'date') {
$morecss = 'minwidth100imp';
} elseif ($type == 'datetime' || $type == 'link') {
@ -976,6 +1023,10 @@ class ExtraFields
$morecss = 'minwidth400';
}
}
// If css forced in attribute, we use this one
if (!empty($this->attributes[$extrafieldsobjectkey]['css'][$key])) {
$morecss = $this->attributes[$extrafieldsobjectkey]['css'][$key];
}
}
if (in_array($type, array('date'))) {
@ -1034,7 +1085,7 @@ class ExtraFields
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').'>';
} elseif (preg_match('/varchar/', $type)) {
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').'>';
} elseif (in_array($type, array('mail', 'phone', 'url'))) {
} elseif (in_array($type, array('mail', 'ip', 'phone', 'url'))) {
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').'>';
} elseif ($type == 'text') {
if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field
@ -1594,6 +1645,8 @@ class ExtraFields
$value = '<input type="checkbox" '.$checked.' '.($moreparam ? $moreparam : '').' readonly disabled>';
} elseif ($type == 'mail') {
$value = dol_print_email($value, 0, 0, 0, 64, 1, 1);
} elseif ($type == 'ip') {
$value = dol_print_ip($value, 0);
} elseif ($type == 'url') {
$value = dol_print_url($value, '_blank', 32, 1);
} elseif ($type == 'phone') {

View File

@ -1291,6 +1291,7 @@ class FormFile
$nboflines++;
print '<!-- Line list_of_documents '.$key.' relativepath = '.$relativepath.' -->'."\n";
// Do we have entry into database ?
print '<!-- In database: position='.(array_key_exists('position', $filearray[$key]) ? $filearray[$key]['position'] : 0).' -->'."\n";
print '<tr class="oddeven" id="row-'.((array_key_exists('rowid', $filearray[$key]) && $filearray[$key]['rowid'] > 0) ? $filearray[$key]['rowid'] : 'AFTER'.$lastrowid.'POS'.($i + 1)).'">';
@ -1436,7 +1437,7 @@ class FormFile
if ($permtoeditline) {
// Link to resize
$moreparaminurl = '';
if ($object->id > 0) {
if (!empty($object->id) && $object->id > 0) {
$moreparaminurl = '&id='.$object->id;
} elseif (GETPOST('website', 'alpha')) {
$moreparaminurl = '&website='.GETPOST('website', 'alpha');

View File

@ -7167,6 +7167,8 @@ function dol_textishtml($msg, $option = 0)
}
return false;
} else {
// Remove all urls because 'http://aa?param1=abc&amp;param2=def' must not be used inside detection
$msg = preg_replace('/https?:\/\/[^"\'\s]+/i', '', $msg);
if (preg_match('/<html/i', $msg)) {
return true;
} elseif (preg_match('/<body/i', $msg)) {
@ -7188,6 +7190,7 @@ function dol_textishtml($msg, $option = 0)
} elseif (preg_match('/<h[0-9]>/i', $msg)) {
return true;
} elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg)) {
// TODO If content is 'A link https://aaa?param=abc&amp;param2=def', it return true but must be false
return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp)
} elseif (preg_match('/&#[0-9]{2,3};/i', $msg)) {
return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp)
@ -7829,6 +7832,7 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null, $con
} else {
if (! $msgishtml) {
$valueishtml = dol_textishtml($value, 1);
var_dump("valueishtml=".$valueishtml);
if ($valueishtml) {
$text = dol_htmlentitiesbr($text);

View File

@ -2271,6 +2271,7 @@ function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu =
$newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'holiday', 0, '', '', '', img_picto('', 'holiday', 'class="pictofixedwidth"'));
$newmenu->add("/holiday/card.php?mainmenu=hrm&leftmenu=holiday&action=create", $langs->trans("New"), 1, $user->rights->holiday->write, '', $mainmenu);
$newmenu->add("/holiday/card_group.php?mainmenu=hrm&leftmenu=holiday&action=request", $langs->trans("NewHolidayForGroup"), 1, ($user->rights->holiday->writeall && $user->rights->holiday->readall), '', $mainmenu, 'holiday_sm');
$newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("List"), 1, $user->rights->holiday->read, '', $mainmenu);
if ($usemenuhider || empty($leftmenu) || $leftmenu == "holiday") {
$newmenu->add("/holiday/list.php?search_status=1&mainmenu=hrm&leftmenu=holiday", $langs->trans("DraftCP"), 2, $user->rights->holiday->read, '', $mainmenu, 'holiday_sm');

View File

@ -275,6 +275,7 @@ class ExportCsv extends ModeleExports
$newvalue = $outputlangs->transnoentities($reg[1]);
}
// Clean data and add encloser if required (depending on value of USE_STRICT_CSV_RULES)
$newvalue = $this->csvClean($newvalue, $outputlangs->charset_output);
if (preg_match('/^Select:/i', $typefield) && $typefield = substr($typefield, 7)) {
@ -338,13 +339,16 @@ class ExportCsv extends ModeleExports
$newvalue = dol_htmlcleanlastbr($newvalue);
//print $charset.' '.$newvalue."\n";
// Rule 1 CSV: No CR, LF in cells (except if USE_STRICT_CSV_RULES is on, we can keep record as it is but we must add quotes)
// Rule 1 CSV: No CR, LF in cells (except if USE_STRICT_CSV_RULES is 1, we can keep record as it is but we must add quotes)
$oldvalue = $newvalue;
$newvalue = str_replace("\r", '', $newvalue);
$newvalue = str_replace("\n", '\n', $newvalue);
if (!empty($conf->global->USE_STRICT_CSV_RULES) && $oldvalue != $newvalue) {
// If strict use of CSV rules, we just add quote
$newvalue = $oldvalue;
// If we must use enclusure on text with CR/LF)
if ($conf->global->USE_STRICT_CSV_RULES == 1) {
// If we use strict CSV rules (original value must remain but we add quote)
$newvalue = $oldvalue;
}
$addquote = 1;
}

View File

@ -497,10 +497,12 @@ class modFacture extends DolibarrModules
$r = 1;
$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe";
$this->export_code[$r] = $this->rights_class.'_'.$r;
$this->export_label[$r] = 'CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r] = 'invoice';
$this->export_permission[$r] = array(array("facture", "facture", "export", "other"));
$this->export_fields_array[$r] = array(
's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 'ps.nom' => 'ParentCompany', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 'cd.nom'=>'State',
's.phone'=>'Phone',
@ -508,18 +510,14 @@ class modFacture extends DolibarrModules
's.code_compta'=>'CustomerAccountancyCode',
's.code_compta_fournisseur'=>'SupplierAccountancyCode',
's.tva_intra'=>'VATIntra',
't.libelle'=>"ThirdPartyType", // 'ce.code'=>"Staff", "cfj.libelle"=>"JuridicalStatus",
'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer',
'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total_ht'=>"TotalHT",
'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.localtax1'=>'LT1', 'f.localtax2'=>'LT2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment',
'none.rest'=>'Rest',
'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic", 'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin',
'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription",
'fd.subprice'=>"LineUnitPrice", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.total_ht'=>"LineTotalHT", 'fd.total_tva'=>"LineTotalVAT",
'fd.total_ttc'=>"LineTotalTTC", 'fd.date_start'=>"DateStart", 'fd.date_end'=>"DateEnd", 'fd.special_code'=>'SpecialCode',
'fd.product_type'=>"TypeOfLineServiceOrProduct", 'fd.fk_product'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel',
$alias_product_perentity . '.accountancy_code_sell'=>'ProductAccountancySellCode',
'aa.account_number' => 'AccountingAffectation'
'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic"
);
// Add multicurrency fields
if (!empty($conf->multicurrency->enabled)) {
$this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency';
$this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate';
@ -527,10 +525,16 @@ class modFacture extends DolibarrModules
$this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';
$this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';
}
// Add POS fields
if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->INVOICE_SHOW_POS)) {
$this->export_fields_array[$r]['f.module_source'] = 'Module';
$this->export_fields_array[$r]['f.pos_source'] = 'POSTerminal';
}
$this->export_fields_array[$r] = $this->export_fields_array[$r] + array(
'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin',
'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin',
'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel'
);
// Add multicompany field
if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) {
$nbofallowedentities = count(explode(',', getEntity('invoice')));
@ -538,28 +542,37 @@ class modFacture extends DolibarrModules
$this->export_fields_array[$r]['f.entity'] = 'Entity';
}
}
$this->export_fields_array[$r] = $this->export_fields_array[$r] + array(
'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription",
'fd.subprice'=>"LineUnitPrice", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.total_ht'=>"LineTotalHT", 'fd.total_tva'=>"LineTotalVAT",
'fd.total_ttc'=>"LineTotalTTC", 'fd.date_start'=>"DateStart", 'fd.date_end'=>"DateEnd", 'fd.special_code'=>'SpecialCode',
'fd.product_type'=>"TypeOfLineServiceOrProduct", 'fd.fk_product'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel',
$alias_product_perentity . '.accountancy_code_sell'=>'ProductAccountancySellCode',
'aa.account_number' => 'AccountingAffectation'
);
$this->export_TypeFields_array[$r] = array(
's.rowid'=>'Numeric', 's.nom'=>'Text', 'ps.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text',
's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
't.libelle'=>"Text", // 'ce.code'=>"List:c_effectif:libelle:code", "cfj.libelle"=>"Text",
'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date", 'f.fk_mode_reglement'=>'Numeric',
'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric', 'f.close_code'=>'Text', 'f.close_note'=>'Text',
'none.rest'=>"NumericCompute",
'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text',
'f.note_private'=>"Text", 'f.note_public'=>"Text",
'f.module_source' => 'Text',
'f.pos_source' => 'Text',
'f.entity'=>'List:entity:label:rowid',
'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text',
'pj.ref'=>'Text', 'pj.title'=>'Text', 'fd.rowid'=>'Numeric', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric",
'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_tva'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.date_start'=>"Date", 'fd.date_end'=>"Date",
'fd.special_code'=>'Numeric', 'fd.product_type'=>"Numeric", 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text',
$alias_product_perentity . '.accountancy_code_sell'=>'Text',
'f.entity'=>'List:entity:label:rowid',
'aa.account_number' => 'Text'
);
if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->INVOICE_SHOW_POS)) {
$this->export_TypeFields_array[$r]['f.module_source'] = 'Text';
$this->export_TypeFields_array[$r]['f.pos_source'] = 'Text';
}
$this->export_entities_array[$r] = array(
's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.code_client'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 'cd.nom'=>'company', 's.phone'=>'company',
's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company',
's.tva_intra'=>'company', 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>'invoice_line', 'fd.description'=>"invoice_line",
's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', 's.tva_intra'=>'company',
't.libelle'=>'company', // 'ce.code'=>'company', 'cfj.libelle'=>'company'
'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>'invoice_line', 'fd.description'=>"invoice_line",
'fd.subprice'=>"invoice_line", 'fd.total_ht'=>"invoice_line", 'fd.total_tva'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.tva_tx'=>"invoice_line",
'fd.qty'=>"invoice_line", 'fd.date_start'=>"invoice_line", 'fd.date_end'=>"invoice_line", 'fd.special_code'=>'invoice_line',
'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product', 'p.ref'=>'product', 'p.label'=>'product', $alias_product_perentity . '.accountancy_code_sell'=>'product',
@ -588,6 +601,7 @@ class modFacture extends DolibarrModules
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra4 ON s.rowid = extra4.fk_object';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as ps ON ps.rowid = s.parent';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';
if (empty($user->rights->societe->client->voir)) {
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
}

View File

@ -29,9 +29,9 @@ if (!empty($extrafieldsobjectkey)) { // $extrafieldsobject is the $object->table
print '<td class="liste_titre'.($cssclass ? ' '.$cssclass : '').'">';
$tmpkey = preg_replace('/'.$search_options_pattern.'/', '', $key);
if (in_array($typeofextrafield, array('varchar', 'int', 'double')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) {
if (in_array($typeofextrafield, array('varchar', 'mail', 'ip', 'url', 'int', 'double')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) {
$searchclass = '';
if (in_array($typeofextrafield, array('varchar'))) {
if (in_array($typeofextrafield, array('varchar', 'mail', 'ip', 'url'))) {
$searchclass = 'searchstring';
}
if (in_array($typeofextrafield, array('int', 'double'))) {

View File

@ -36,7 +36,7 @@ if (!empty($extrafieldsobjectkey)) { // $extrafieldsobject is the $object->table
$tooltip = empty($extrafields->attributes[$extrafieldsobjectkey]['help'][$key]) ? '' : $extrafields->attributes[$extrafieldsobjectkey]['help'][$key];
print getTitleFieldOfList($extrafields->attributes[$extrafieldsobjectkey]['label'][$key], 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($cssclass ? 'class="'.$cssclass.'" data-titlekey="'.$key.'"' : 'data-titlekey="'.$key.'"'), $sortfield, $sortorder, '', $disablesortlink, $tooltip)."\n";
print getTitleFieldOfList($extrafields->attributes[$extrafieldsobjectkey]['label'][$key], 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, 'data-titlekey="'.$key.'"', $sortfield, $sortorder, $cssclass.' ', $disablesortlink, $tooltip)."\n";
if (isset($totalarray) && isset($totalarray['nbfield'])) {
$totalarray['nbfield']++;
}

View File

@ -54,7 +54,9 @@ if ($module == 'medias') {
$showroot = 1;
}
if (!isset($section)) {
$section = 0;
}
// Confirm remove file (for non javascript users)
if (($action == 'delete' || $action == 'file_manager_delete') && empty($conf->use_javascript_ajax)) {
@ -106,12 +108,26 @@ $('#acreatedir').on('click', function() {
try{
section_dir = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].rel;
section = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].id.split('_')[2];
catParent = ";
if ($module == 'ecm') {
print "section;";
} else {
print "section_dir.substring(0, section_dir.length - 1);";
}
print "
} catch{
section_dir = '/';
section = 0;
catParent = ";
if ($module == 'ecm') {
print "section;";
} else {
print "section_dir;";
}
print "
}
console.log('We click to create a new directory, we set current section_dir='+section_dir+' into href url of button acreatedir');
$('#acreatedir').attr('href', $('#acreatedir').attr('href')+'&section_dir='+encodeURI(section_dir)+'&section='+encodeURI(section));
$('#acreatedir').attr('href', $('#acreatedir').attr('href')+'%26section_dir%3D'+encodeURI(section_dir)+'%26section%3D'+encodeURI(section)+'&section_dir='+encodeURI(section_dir)+'&section='+encodeURI(section)+'&catParent='+encodeURI(catParent));
console.log($('#acreatedir').attr('href'));
});
$('#agenerateimgwebp').on('click', function() {

View File

@ -258,7 +258,7 @@ llxHeader('', $langs->trans("CronTask"));
$head = cron_prepare_head($object);
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("CronTask"), '', 'title_setup');
}

View File

@ -259,7 +259,7 @@ llxHeader('', $title, 'Livraison');
$form = new Form($db);
$formfile = new FormFile($db);
if ($action == 'create') { // Create. Seems to no be used
if ($action == 'create' || (empty($action) && empty($id))) { // Create. Seems to no be used
} else // View
{
if ($object->id > 0) {

View File

@ -386,7 +386,7 @@ if (!empty($conf->project->enabled)) {
$formproject = new FormProjets($db);
}
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("AddDonation"), '', 'object_donation');
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">';

View File

@ -206,7 +206,7 @@ llxHeader('', $langs->trans("ECMNewSection"));
$form = new Form($db);
$formecm = new FormEcm($db);
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
//***********************
// Create
//***********************
@ -230,7 +230,7 @@ if ($action == 'create') {
print '<table class="border centpercent">';
// Label
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input name="label" class="minwidth100" maxlength="32" value="'.$ecmdir->label.'" autofocus></td></tr>'."\n";
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input name="label" class="minwidth100" maxlength="32" value="'.(GETPOST("label", 'alpha') ? GETPOST("label", 'alpha') : $ecmdir->label).'" autofocus></td></tr>'."\n";
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print $formecm->selectAllSections((GETPOST("catParent", 'alpha') ? GETPOST("catParent", 'alpha') : $ecmdir->fk_parent), 'catParent', $module);

View File

@ -166,7 +166,7 @@ $title = $langs->trans("ConferenceOrBooth");
$help_url = '';
llxHeader('', $title, $help_url);
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
$result = $projectstatic->fetch(GETPOST('fk_project'));
} else {
$result = $projectstatic->fetch($object->fk_project);
@ -392,7 +392,7 @@ if (!empty($withproject)) {
}
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("ConferenceOrBooth")), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -420,7 +420,7 @@ if (!empty($withproject)) {
}
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("ConferenceOrBoothAttendee")), '', 'object_'.$object->picto);

View File

@ -835,7 +835,7 @@ if ($action == 'create2') {
}
// Mode creation.
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
$expe = new Expedition($db);
print load_fiche_titre($langs->trans("CreateShipment"), '', 'dolly');

View File

@ -898,6 +898,7 @@ class Expedition extends CommonObject
* Add an expedition line.
* If STOCK_WAREHOUSE_NOT_REQUIRED_FOR_SHIPMENTS is set, you can add a shipment line, with no stock source defined
* If STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT is not set, you can add a shipment line, even if not enough into stock
* Note: For product that need a batch number, you must use addline_batch()
*
* @param int $entrepot_id Id of warehouse
* @param int $id Id of source line (order line)

View File

@ -1389,7 +1389,7 @@ $ecmfilesstatic = new EcmFiles($db);
$formexpensereport = new FormExpenseReport($db);
// Create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewTrip"), '', 'trip');
print '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="create">';

View File

@ -796,7 +796,7 @@ $help_url = 'EN:Module_Interventions';
llxHeader('', $langs->trans("Intervention"), $help_url);
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
// Create new intervention
$soc = new Societe($db);

View File

@ -34,7 +34,7 @@ if (!defined('DOL_APPLICATION_TITLE')) {
define('DOL_APPLICATION_TITLE', 'Dolibarr');
}
if (!defined('DOL_VERSION')) {
define('DOL_VERSION', '16.0.0'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
define('DOL_VERSION', '17.0.0-alpha'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
}
if (!defined('EURO')) {

View File

@ -79,6 +79,9 @@ class CommandeFournisseurDispatch extends CommonObjectLine
*/
public $fk_commandefourndet;
public $fk_reception;
public $qty;
public $qty_asked;

View File

@ -1547,7 +1547,7 @@ llxHeader('', $title, $help_url);
$now = dol_now();
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans('NewOrderSupplier'), '', 'supplier_order');
dol_htmloutput_events();

View File

@ -1902,7 +1902,7 @@ $help_url = 'EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Mó
llxHeader('', $title, $help_url);
// Mode creation
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
$facturestatic = new FactureFournisseur($db);
print load_fiche_titre($langs->trans('NewSupplierInvoice'), '', 'supplier_invoice');

View File

@ -0,0 +1,789 @@
<?php
/* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
* Copyright (C) 2012-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012-2016 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014-2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2020-2021 Udo Tamm <dev@dolibit.de>
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
*
* 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, orwrite
* (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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/holiday/card.php
* \ingroup holiday
* \brief Form and file creation of paid holiday.
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php';
require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
// Get parameters
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$fuserid = (GETPOST('fuserid', 'int') ?GETPOST('fuserid', 'int') : $user->id);
$users = (GETPOST('users', 'array') ?GETPOST('users', 'array') : array($user->id));
$groups = GETPOST('groups', 'array');
$socid = GETPOST('socid', 'int');
$autoValidation = GETPOST('autoValidation', 'int');
$AutoSendMail = GETPOST('AutoSendMail', 'int');
// Load translation files required by the page
$langs->loadLangs(array("other", "holiday", "mails", "trips"));
$error = 0;
$now = dol_now();
$childids = $user->getAllChildIds(1);
$morefilter = '';
if (!empty($conf->global->HOLIDAY_HIDE_FOR_NON_SALARIES)) {
$morefilter = 'AND employee = 1';
}
$object = new Holiday($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
if (($id > 0) || $ref) {
$object->fetch($id, $ref);
// Check current user can read this leave request
$canread = 0;
if (!empty($user->rights->holiday->readall)) {
$canread = 1;
}
if (!empty($user->rights->holiday->read) && in_array($object->fk_user, $childids)) {
$canread = 1;
}
if (!$canread) {
accessforbidden();
}
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('holidaycard', 'globalcard'));
$cancreate = 0;
$cancreateall = 0;
if (!empty($user->rights->holiday->write) && in_array($fuserid, $childids)) {
$cancreate = 1;
}
if (!empty($user->rights->holiday->writeall)) {
$cancreate = 1;
$cancreateall = 1;
}
$candelete = 0;
if (!empty($user->rights->holiday->delete)) {
$candelete = 1;
}
if ($object->statut == Holiday::STATUS_DRAFT && $user->rights->holiday->write && in_array($object->fk_user, $childids)) {
$candelete = 1;
}
// Protection if external user
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'holiday', $object->id, 'holiday', '', '', 'rowid', $object->statut);
/*
* Actions
*/
$parameters = array('socid' => $socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) {
$backurlforlist = DOL_URL_ROOT.'/holiday/list.php';
if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
$backtopage = $backurlforlist;
} else {
$backtopage = DOL_URL_ROOT.'/holiday/card_group.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
}
}
}
if ($cancel) {
if (!empty($backtopageforcancel)) {
header("Location: ".$backtopageforcancel);
exit;
} elseif (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
$action = '';
}
// Add leave request
if ($action == 'add') {
// If no right to create a request
if (!$cancreate) {
$error++;
setEventMessages($langs->trans('CantCreateCP'), null, 'errors');
$action = 'create';
}
if (!$error) {
$users = GETPOST('users', 'array');
$groups = GETPOST('groups', 'array');
$date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
$date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
$date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1);
$date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1);
$starthalfday = GETPOST('starthalfday');
$endhalfday = GETPOST('endhalfday');
$type = GETPOST('type');
$halfday = 0;
if ($starthalfday == 'afternoon' && $endhalfday == 'morning') {
$halfday = 2;
} elseif ($starthalfday == 'afternoon') {
$halfday = -1;
} elseif ($endhalfday == 'morning') {
$halfday = 1;
}
$approverid = GETPOST('valideur', 'int');
$description = trim(GETPOST('description', 'restricthtml'));
// Check that leave is for a user inside the hierarchy or advanced permission for all is set
if (!$cancreateall) {
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
if (empty($user->rights->holiday->write)) {
$error++;
setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
} elseif (!in_array($fuserid, $childids)) {
$error++;
setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors');
$action = 'create';
}
} else {
if (empty($user->rights->holiday->write) && empty($user->rights->holiday->writeall_advance)) {
$error++;
setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
} elseif (empty($user->rights->holiday->writeall_advance) && !in_array($fuserid, $childids)) {
$error++;
setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors');
$action = 'create';
}
}
}
// If no groups and no users
if (empty($groups) && empty($users)) {
setEventMessages($langs->trans("ErrorFieldRequiredUserOrGroup"), null, 'errors');
//setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UserOrGroup")), null, 'errors');
//setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Group")), null, 'errors');
$error++;
$action = 'create';
}
// If no type
if ($type <= 0) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
$error++;
$action = 'create';
}
// If no start date
if (empty($date_debut)) {
setEventMessages($langs->trans("NoDateDebut"), null, 'errors');
$error++;
$action = 'create';
}
// If no end date
if (empty($date_fin)) {
setEventMessages($langs->trans("NoDateFin"), null, 'errors');
$error++;
$action = 'create';
}
// If start date after end date
if ($date_debut > $date_fin) {
setEventMessages($langs->trans("ErrorEndDateCP"), null, 'errors');
$error++;
$action = 'create';
}
// If there is no Business Days within request
$nbopenedday = num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
if ($nbopenedday < 0.5) {
setEventMessages($langs->trans("ErrorDureeCP"), null, 'errors'); // No working day
$error++;
$action = 'create';
}
// If no validator designated
if ($approverid < 1) {
setEventMessages($langs->transnoentitiesnoconv('InvalidValidatorCP'), null, 'errors');
$error++;
}
$result = 0;
if (!$error) {
$TusersToProcess = array();
// usergroup select
// better perf on single sql
/** GROUPS */
$sql = ' SELECT DISTINCT u.rowid,u.lastname,u.firstname from ' . MAIN_DB_PREFIX . 'user as u';
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'usergroup_user as ug on ug.fk_user = u.rowid ';
$sql .= ' WHERE fk_usergroup in (' .$db->sanitize(implode(',', $groups)) . ')';
$resql = $db->query($sql);
if ($resql) {
while ($obj = $db->fetch_object($resql)) {
$TusersToProcess[$obj->rowid] = $obj->rowid;
}
}
/** USERS */
if (is_array($users) && count($users) > 0) {
foreach ($users as $u) {
$TusersToProcess[$u] = $u;
}
}
foreach ($TusersToProcess as $u) {
// Check if there is already holiday for this period pour chaque user
$verifCP = $object->verifDateHolidayCP($u, $date_debut, $date_fin, $halfday);
if (!$verifCP) {
//setEventMessages($langs->trans("alreadyCPexist"), null, 'errors');
$userError = new User($db);
$result = $userError->fetch($u);
if ($result) {
setEventMessages($langs->trans("UseralreadyCPexist", $userError->firstname . ' '. $userError->lastname), null, 'errors');
} else {
setEventMessages($langs->trans("ErrorUserFetch", $u), null, 'errors');
}
$error++;
$action = 'create';
}
}
if (!$error) {
$db->begin();
// non errors we can insert all
foreach ($TusersToProcess as $u) {
$object = new Holiday($db);
$object->fk_user = $u;
$object->description = $description;
$object->fk_validator = $approverid;
$object->fk_type = $type;
$object->date_debut = $date_debut;
$object->date_fin = $date_fin;
$object->halfday = $halfday;
$result = $object->create($user);
if ($result <= 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
} else {
//@TODO changer le nom si validated
if ($autoValidation) {
$htemp = new Holiday($db);
$htemp->fetch($result);
$htemp->statut = Holiday::STATUS_VALIDATED;
$resultValidated = $htemp->update($approverid);
if ($resultValidated < 0 ) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
// we can auto send mail if we are in auto validation behavior
if ($AutoSendMail && !$error) {
// send a mail to the user
$returnSendMail = sendMail($result, $cancreate, $now, $autoValidation);
if (!empty($returnSendMail->msg)) setEventMessage($returnSendMail->msg, $returnSendMail->style);
}
}
}
}
}
// If no SQL error we redirect to the request card
if (!$error) {
$db->commit();
header('Location: '.DOL_URL_ROOT.'/holiday/list.php');
exit;
} else {
$db->rollback();
}
}
}
}
}
/*
* View
*/
$form = new Form($db);
$object = new Holiday($db);
$listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon"));
$title = $langs->trans('Leave');
$help_url = 'EN:Module_Holiday';
llxHeader('', $title, $help_url);
if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') {
// If user has no permission to create a leave
if ((in_array($fuserid, $childids) && empty($user->rights->holiday->writeall)) || (!in_array($fuserid, $childids) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->holiday->writeall_advance)))) {
$errors[] = $langs->trans('CantCreateCP');
} else {
// Form to add a leave request
print load_fiche_titre($langs->trans('MenuCollectiveAddCP'), '', 'title_hrm.png');
// Error management
if (GETPOST('error')) {
switch (GETPOST('error')) {
case 'datefin':
$errors[] = $langs->trans('ErrorEndDateCP');
break;
case 'SQL_Create':
$errors[] = $langs->trans('ErrorSQLCreateCP').' <b>'.htmlentities($_GET['msg']).'</b>';
break;
case 'CantCreate':
$errors[] = $langs->trans('CantCreateCP');
break;
case 'Valideur':
$errors[] = $langs->trans('InvalidValidatorCP');
break;
case 'nodatedebut':
$errors[] = $langs->trans('NoDateDebut');
break;
case 'nodatefin':
$errors[] = $langs->trans('NoDateFin');
break;
case 'DureeHoliday':
$errors[] = $langs->trans('ErrorDureeCP');
break;
case 'alreadyCP':
$errors[] = $langs->trans('alreadyCPexist');
break;
}
setEventMessages($errors, null, 'errors');
}
print '<script type="text/javascript">
$( document ).ready(function() {
if( $("input[name=autoValidation]").is(":checked") ){
$("#AutoSendMail").prop("disabled", false);
$("#AutoSendMail").prop("checked", true);
} else {
$("#AutoSendMail").prop("disabled", true);
$("#AutoSendMail").prop("checked", false);
}
$("input[name=autoValidation]").click( function(e) {
if( $("input[name=autoValidation]").is(":checked") ){
$("#AutoSendMail").prop("disabled", false);
$("#AutoSendMail").prop("checked", true);
} else {
$("#AutoSendMail").prop("disabled", true);
$("#AutoSendMail").prop("checked", false);
}
});
$("input.button-save").click("submit", function(e) {
console.log("Call valider()");
if (document.demandeCP.date_debut_.value != "")
{
if(document.demandeCP.date_fin_.value != "")
{
if(document.demandeCP.valideur.value != "-1") {
return true;
}
else {
alert("'.dol_escape_js($langs->transnoentities('InvalidValidatorCP')).'");
return false;
}
}
else
{
alert("'.dol_escape_js($langs->transnoentities('NoDateFin')).'");
return false;
}
}
else
{
alert("'.dol_escape_js($langs->transnoentities('NoDateDebut')).'");
return false;
}
})
$("#autoValidation").change(function(){
if( $("input[name=autoValidation]").is(":checked") ){
$("#AutoSendMail").prop("disabled", false);
} else {
$("#AutoSendMail").prop("disabled", true);
$("#AutoSendMail").prop("checked", false);
}
})
});
</script>'."\n";
// Formulaire de demande
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="demandeCP">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'" />'."\n";
print '<input type="hidden" name="action" value="add" />'."\n";
print dol_get_fiche_head();
print '<table class="border centpercent">';
print '<tbody>';
// groupe
print '<tr>';
print '<td class="titlefield fieldrequired">';
print $form->textwithpicto($langs->trans("groups"), $langs->trans("fusionGroupsUsers"));
print '</td>';
print '<td>';
//@todo ajouter entity !
$sql =' SELECT rowid, nom from '.MAIN_DB_PREFIX.'usergroup ';
$resql = $db->query($sql);
$Tgroup = array();
while ($obj = $db->fetch_object($resql)) {
$Tgroup[$obj->rowid] = $obj->nom;
}
print $form->multiselectarray('groups', $Tgroup, GETPOST('groups', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
print '</td>';
// users
print '<tr>';
print '<td class="titlefield fieldrequired">';
print $form->textwithpicto($langs->trans("users"), $langs->trans("fusionGroupsUsers"));
print '<td>';
$sql = ' SELECT DISTINCT u.rowid,u.lastname,u.firstname from '.MAIN_DB_PREFIX.'user as u';
$sql .= ' WHERE 1=1 ';
$sql .= !empty($morefilter) ? $morefilter : '';
$resql = $db->query($sql);
if ($resql) {
while ($obj = $db->fetch_object($resql)) {
$userlist[$obj->rowid] = $obj->firstname . ' '. $obj->lastname;
}
}
print img_picto('', 'users') . $form->multiselectarray('users', $userlist, GETPOST('users', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
print '</td>';
// Type
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("Type").'</td>';
print '<td>';
$typeleaves = $object->getTypes(1, -1);
$arraytypeleaves = array();
foreach ($typeleaves as $key => $val) {
$labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']);
$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')' : '');
$arraytypeleaves[$val['rowid']] = $labeltoshow;
}
print $form->selectarray('type', $arraytypeleaves, (GETPOST('type', 'alpha') ?GETPOST('type', 'alpha') : ''), 1, 0, 0, '', 0, 0, 0, '', '', true);
if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
print '</td>';
print '</tr>';
// Date start
print '<tr>';
print '<td class="fieldrequired">';
print $form->textwithpicto($langs->trans("DateDebCP"), $langs->trans("FirstDayOfHoliday"));
print '</td>';
print '<td>';
// Si la demande ne vient pas de l'agenda
if (!GETPOST('date_debut_')) {
print $form->selectDate(-1, 'date_debut_', 0, 0, 0, '', 1, 1);
} else {
$tmpdate = dol_mktime(0, 0, 0, GETPOST('date_debut_month', 'int'), GETPOST('date_debut_day', 'int'), GETPOST('date_debut_year', 'int'));
print $form->selectDate($tmpdate, 'date_debut_', 0, 0, 0, '', 1, 1);
}
print ' &nbsp; &nbsp; ';
print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday', 'alpha') ?GETPOST('starthalfday', 'alpha') : 'morning'));
print '</td>';
print '</tr>';
// Date end
print '<tr>';
print '<td class="fieldrequired">';
print $form->textwithpicto($langs->trans("DateFinCP"), $langs->trans("LastDayOfHoliday"));
print '</td>';
print '<td>';
if (!GETPOST('date_fin_')) {
print $form->selectDate(-1, 'date_fin_', 0, 0, 0, '', 1, 1);
} else {
$tmpdate = dol_mktime(0, 0, 0, GETPOST('date_fin_month', 'int'), GETPOST('date_fin_day', 'int'), GETPOST('date_fin_year', 'int'));
print $form->selectDate($tmpdate, 'date_fin_', 0, 0, 0, '', 1, 1);
}
print ' &nbsp; &nbsp; ';
print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday', 'alpha') ?GETPOST('endhalfday', 'alpha') : 'afternoon'));
print '</td>';
print '</tr>';
// Approver
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("ReviewedByCP").'</td>';
print '<td>';
$object = new Holiday($db);
$include_users = $object->fetch_users_approver_holiday();
if (empty($include_users)) {
print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays");
} else {
// Defined default approver (the forced approved of user or the supervisor if no forced value defined)
// Note: This use will be set only if the deinfed approvr has permission to approve so is inside include_users
$defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator);
if (!empty($conf->global->HOLIDAY_DEFAULT_VALIDATOR)) {
$defaultselectuser = $conf->global->HOLIDAY_DEFAULT_VALIDATOR; // Can force default approver
}
if (GETPOST('valideur', 'int') > 0) {
$defaultselectuser = GETPOST('valideur', 'int');
}
$s = $form->select_dolusers($defaultselectuser, "valideur", 1, '', 0, $include_users, '', '0,'.$conf->entity, 0, 0, '', 0, '', 'minwidth200 maxwidth500');
print img_picto('', 'user').$form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate"));
}
print '</td>';
print '</tr>';
//auto validation ON CREATE
print '<tr><td>'.$langs->trans("AutoValidationOnCreate").'</td><td>';
print '<input type="checkbox" id="autoValidation" name="autoValidation" value="1"'.($autoValidation ? ' checked="checked"' : '').'>';
print '</td></tr>'."\n";
//no auto SEND MAIL
print '<tr><td>'.$langs->trans("AutoSendMail").'</td><td>';
print '<input type="checkbox" id="AutoSendMail" name="AutoSendMail" value="1"'.($AutoSendMail ? ' checked="checked"' : '').'>';
print '</td></tr>'."\n";
// Description
print '<tr>';
print '<td>'.$langs->trans("DescCP").'</td>';
print '<td class="tdtop">';
$doleditor = new DolEditor('description', GETPOST('description', 'restricthtml'), '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, ROWS_3, '90%');
print $doleditor->Create(1);
print '</td></tr>';
// Other attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
print '</tbody>';
print '</table>';
print dol_get_fiche_end();
print $form->buttonsSaveCancel("SendRequestCollectiveCP");
print '</from>'."\n";
}
} else {
if ($error) {
print '<div class="tabBar">';
print $error;
print '<br><br><input type="button" value="'.$langs->trans("ReturnCP").'" class="button" onclick="history.go(-1)" />';
print '</div>';
}
}
// End of page
llxFooter();
if (is_object($db)) {
$db->close();
}
/**
* send email to validator for current leave represented by (id)
* @param $id validator for current leave represented by (id)
* @param $cancreate flag for user right
* @param $now date
* @param $autoValidation boolean flag on autovalidation
* @return stdClass
* @throws Exception
*/
function sendMail($id, $cancreate, $now, $autoValidation)
{
$objStd = new stdClass();
$objStd->msg = '';
$objStd->status = 'success';
$objStd->error = 0;
$objStd->style = '';
global $db, $user, $conf, $langs;
$object = new Holiday($db);
$result = $object->fetch($id);
if ($result) {
// If draft and owner of leave
if ($object->statut == Holiday::STATUS_VALIDATED && $cancreate) {
$object->oldcopy = dol_clone($object);
//if ($autoValidation) $object->statut = Holiday::STATUS_VALIDATED;
$verif = $object->validate($user);
if ($verif > 0) {
// To
$destinataire = new User($db);
$destinataire->fetch($object->fk_validator);
$emailTo = $destinataire->email;
if (!$emailTo) {
dol_syslog("Expected validator has no email, so we redirect directly to finished page without sending email");
$objStd->error++;
$objStd->msg = $langs->trans('ErroremailTo');
$objStd->status = 'error';
$objStd->style="warnings";
return $objStd;
}
// From
$expediteur = new User($db);
$expediteur->fetch($object->fk_user);
//$emailFrom = $expediteur->email; Email of user can be an email into another company. Sending will fails, we must use the generic email.
$emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM;
// Subject
$societeName = $conf->global->MAIN_INFO_SOCIETE_NOM;
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
$societeName = $conf->global->MAIN_APPLICATION_TITLE;
}
$subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysToValidate");
// Content
$message = "<p>".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",</p>\n";
$message .= "<p>".$langs->transnoentities("HolidaysToValidateBody")."</p>\n";
// option to warn the validator in case of too short delay
if (empty($conf->global->HOLIDAY_HIDE_APPROVER_ABOUT_TOO_LOW_DELAY)) {
$delayForRequest = 0; // TODO Set delay depending of holiday leave type
if ($delayForRequest) {
$nowplusdelay = dol_time_plus_duree($now, $delayForRequest, 'd');
if ($object->date_debut < $nowplusdelay) {
$message = "<p>".$langs->transnoentities("HolidaysToValidateDelay", $delayForRequest)."</p>\n";
}
}
}
// option to notify the validator if the balance is less than the request
if (empty($conf->global->HOLIDAY_HIDE_APPROVER_ABOUT_NEGATIVE_BALANCE)) {
$nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday);
if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) {
$message .= "<p>".$langs->transnoentities("HolidaysToValidateAlertSolde")."</p>\n";
}
}
$link = dol_buildpath("/holiday/card.php", 3) . '?id='.$object->id;
$message .= "<ul>";
$message .= "<li>".$langs->transnoentitiesnoconv("Name")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."</li>\n";
$message .= "<li>".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($object->date_debut, 'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($object->date_fin, 'day')."</li>\n";
$message .= "<li>".$langs->transnoentitiesnoconv("Link").' : <a href="'.$link.'" target="_blank">'.$link."</a></li>\n";
$message .= "</ul>\n";
$trackid = 'leav'.$object->id;
$mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid);
// Sending the email
$result = $mail->sendfile();
if (!$result) {
$objStd->error++;
$objStd->msg = $langs->trans('ErroreSendmail');
$objStd->style="warnings";
$objStd->status = 'error';
} else {
$objStd->msg = $langs->trans('mailSended');
}
return $objStd;
} else {
$objStd->error++;
$objStd->msg = $langs->trans('ErroreVerif');
$objStd->status = 'error';
$objStd->style="errors";
return $objStd;
}
}
} else {
$objStd->error++;
$objStd->msg = $langs->trans('ErrorloadUserOnSendingMail');
$objStd->status = 'error';
$objStd->style="warnings";
return $objStd;
}
return $objStd;
}

View File

@ -1115,11 +1115,11 @@ class Holiday extends CommonObject
$this->fetchByUser($fk_user, '', '');
foreach ($this->holiday as $infos_CP) {
if ($infos_CP['statut'] == 4) {
if ($infos_CP['statut'] == Holiday::STATUS_CANCELED) {
continue; // ignore not validated holidays
}
if ($infos_CP['statut'] == 5) {
continue; // ignore not validated holidays
if ($infos_CP['statut'] == Holiday::STATUS_REFUSED) {
continue; // ignore refused holidays
}
//var_dump("--");
//var_dump("old: ".dol_print_date($infos_CP['date_debut'],'dayhour').' '.dol_print_date($infos_CP['date_fin'],'dayhour').' '.$infos_CP['halfday']);

View File

@ -159,7 +159,7 @@ $formcompany = new FormCompany($db);
/*
* Action create
*/
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewEstablishment"));
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';

View File

@ -255,7 +255,7 @@ print '<script type="text/javascript" language="javascript">
</script>';
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewEval"), '', 'object_' . $object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -180,7 +180,7 @@ llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentities('Job')), '', 'object_' . $object->picto);
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';

View File

@ -187,7 +187,7 @@ llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewSkill"), '', 'object_' . $object->picto);
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';

View File

@ -454,11 +454,12 @@ if (!file_exists($conffile)) {
$migrationscript = array();
$handle = opendir($dir);
if (is_resource($handle)) {
$versiontousetoqualifyscript = preg_replace('/-.*/', '', DOL_VERSION);
while (($file = readdir($handle)) !== false) {
$reg = array();
if (preg_match('/^(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.sql$/i', $file, $reg)) {
//var_dump(DOL_VERSION." ".$reg[2]." ".version_compare(DOL_VERSION, $reg[2]));
if (!empty($reg[2]) && version_compare(DOL_VERSION, $reg[2]) >= 0) {
//var_dump(DOL_VERSION." ".$reg[2]." ".$versiontousetoqualifyscript." ".version_compare($versiontousetoqualifyscript, $reg[2]));
if (!empty($reg[2]) && version_compare($versiontousetoqualifyscript, $reg[2]) >= 0) {
$migrationscript[] = array('from' => $reg[1], 'to' => $reg[2]);
}
}

View File

@ -116,6 +116,7 @@ INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'MRO'
INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'MUR', '[8360]', 1, 'Mauritius Rupee');
INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'MXN', '[36]', 1, 'Mexico Peso');
INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'MDL', NULL, 1, 'Moldova Leu');
INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'MMK', '[75]', 1, 'Myanmar Kyat');
INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'MNT', '[8366]', 1, 'Mongolia Tughrik');
INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'MAD', NULL, 1, 'Morocco Dirham');
INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'MZN', '[77,84]', 1, 'Mozambique Metical');

View File

@ -630,10 +630,11 @@ ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD COLUMN lastname
ALTER TABLE llx_eventorganization_conferenceorboothattendee ADD COLUMN email_company varchar(128) after email;
ALTER TABLE llx_c_email_template ADD COLUMN email_from varchar(255);
ALTER TABLE llx_c_email_template ADD COLUMN email_to varchar(255);
ALTER TABLE llx_c_email_template ADD COLUMN email_tocc varchar(255);
ALTER TABLE llx_c_email_template ADD COLUMN email_tobcc varchar(255);
ALTER TABLE llx_c_email_templates ADD COLUMN joinfiles text;
ALTER TABLE llx_c_email_templates ADD COLUMN email_from varchar(255);
ALTER TABLE llx_c_email_templates ADD COLUMN email_to varchar(255);
ALTER TABLE llx_c_email_templates ADD COLUMN email_tocc varchar(255);
ALTER TABLE llx_c_email_templates ADD COLUMN email_tobcc varchar(255);
ALTER TABLE llx_fichinter ADD COLUMN ref_client varchar(255) after ref_ext;

View File

@ -36,6 +36,11 @@
ALTER TABLE llx_c_action_trigger MODIFY elementtype VARCHAR(64);
ALTER TABLE llx_c_email_templates ADD COLUMN joinfiles text;
ALTER TABLE llx_c_email_templates ADD COLUMN email_from varchar(255);
ALTER TABLE llx_c_email_templates ADD COLUMN email_to varchar(255);
ALTER TABLE llx_c_email_templates ADD COLUMN email_tocc varchar(255);
ALTER TABLE llx_c_email_templates ADD COLUMN email_tobcc varchar(255);
-- v17

View File

@ -156,7 +156,7 @@ if ($action == 'add' && $permissiontoadd) {
*/
// Creation mode
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
$title = $langs->trans("IntracommReportTitle");
llxHeader("", $title);
print load_fiche_titre($langs->trans("IntracommReportTitle"));

View File

@ -169,7 +169,7 @@ $help_url = '';
llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewKnowledgeRecord"), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -2283,3 +2283,5 @@ AccordingToBrowser=According to browser
AlwaysEnabled=Always Enabled
DoesNotWorkWithAllThemes=Will not work with all themes
NoName=No name
ShowAdvancedOptions= Show advanced options
HideAdvancedoptions= Hide advanced options

View File

@ -4,6 +4,7 @@ Holidays=Leave
CPTitreMenu=Leave
MenuReportMonth=Monthly statement
MenuAddCP=New leave request
MenuCollectiveAddCP=New collective leave request
NotActiveModCP=You must enable the module Leave to view this page.
AddCP=Make a leave request
DateDebCP=Start date
@ -79,6 +80,8 @@ MotifCP=Reason
UserCP=User
ErrorAddEventToUserCP=An error occurred while adding the exceptional leave.
AddEventToUserOkCP=The addition of the exceptional leave has been completed.
ErrorFieldRequiredUserOrGroup=The "group" field or the "user" field must be filled in
fusionGroupsUsers=The groups field and the user field will be merged
MenuLogCP=View change logs
LogCP=Log of all updates made to "Balance of Leave"
ActionByCP=Updated by
@ -86,6 +89,13 @@ UserUpdateCP=Updated for
PrevSoldeCP=Previous Balance
NewSoldeCP=New Balance
alreadyCPexist=A leave request has already been done on this period.
UseralreadyCPexist=A leave request has already been done on this period for %s.
groups=Groups
users=Users
AutoSendMail=Automatic mailing
NewHolidayForGroup=New collective leave request
SendRequestCollectiveCP=Send collective leave request
AutoValidationOnCreate=Automatic validation
FirstDayOfHoliday=Beginning day of leave request
LastDayOfHoliday=Ending day of leave request
BoxTitleLastLeaveRequests=Latest %s modified leave requests

View File

@ -259,7 +259,7 @@ TimeSpentInvoiced=Time spent billed
TimeSpentForIntervention=Time spent
TimeSpentForInvoice=Time spent
OneLinePerUser=One line per user
ServiceToUseOnLines=Service to use on lines
ServiceToUseOnLines=Service to use on lines by default
InvoiceGeneratedFromTimeSpent=Invoice %s has been generated from time spent on project
InterventionGeneratedFromTimeSpent=Intervention %s has been generated from time spent on project
ProjectBillTimeDescription=Check if you enter timesheet on tasks of project AND you plan to generate invoice(s) from the timesheet to bill the customer of the project (do not check if you plan to create invoice that is not based on entered timesheets). Note: To generate invoice, go on tab 'Time spent' of the project and select lines to include.

View File

@ -254,7 +254,7 @@ llxHeader("", $title, $help_url);
// Create mode
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
//WYSIWYG Editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -242,7 +242,7 @@ llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
if (empty($permissiontoadd)) {
accessforbidden($langs->trans('NotEnoughPermissions'), 0, 1);
exit;

View File

@ -241,7 +241,7 @@ llxHeader('', $title, '');
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
if (GETPOST('fk_bom', 'int') > 0) {
$titlelist = $langs->trans("ToConsume");
if ($objectbom->bomtype == 1) {

View File

@ -259,7 +259,7 @@ $help_url = '';
llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewPartnership"), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -6159,6 +6159,43 @@ class Product extends CommonObject
dol_print_error($this->db);
}
}
/**
* Return the duration in Hours of a service base on duration fields
* @return int -1 KO, >= 0 is the duration in hours
*/
public function getProductDurationHours()
{
global $langs;
if (empty($this->duration_value)) {
$this->errors[]='ErrorDurationForServiceNotDefinedCantCalculateHourlyPrice';
return -1;
}
if ($this->duration_unit == 'i') {
$prodDurationHours = 1. / 60;
}
if ($this->duration_unit == 'h') {
$prodDurationHours = 1.;
}
if ($this->duration_unit == 'd') {
$prodDurationHours = 24.;
}
if ($this->duration_unit == 'w') {
$prodDurationHours = 24. * 7;
}
if ($this->duration_unit == 'm') {
$prodDurationHours = 24. * 30;
}
if ($this->duration_unit == 'y') {
$prodDurationHours = 24. * 365;
}
$prodDurationHours *= $this->duration_value;
return $prodDurationHours;
}
}

View File

@ -181,7 +181,7 @@ llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewInventory"), '', 'product');
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -27,6 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php';
if (!empty($conf->categorie->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
}
// Load translation files required by the page
$langs->loadLangs(array("stocks", "other"));
@ -88,6 +91,13 @@ foreach ($object->fields as $key => $val) {
$search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
}
}
$searchCategoryProductOperator = 0;
if (GETPOSTISSET('formfilteraction')) {
$searchCategoryProductOperator = GETPOST('search_category_product_operator', 'int');
} elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) {
$searchCategoryProductOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
}
$searchCategoryProductList = GETPOST('search_category_product_list', 'array');
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array();
@ -166,6 +176,7 @@ if (empty($reshook)) {
$search[$key.'_dtend'] = '';
}
}
$searchCategoryProductList = array();
$toselect = array();
$search_array_options = array();
}
@ -259,6 +270,50 @@ foreach ($search as $key => $val) {
if ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
}
$searchCategoryProductSqlList = array();
if ($searchCategoryProductOperator == 1) {
$existsCategoryProductList = array();
foreach ($searchCategoryProductList as $searchCategoryProduct) {
if (intval($searchCategoryProduct) == -2) {
$sqlCategoryProductNotExists = " NOT EXISTS (";
$sqlCategoryProductNotExists .= " SELECT cp.fk_product";
$sqlCategoryProductNotExists .= " FROM ".$db->prefix()."categorie_product AS cp";
$sqlCategoryProductNotExists .= " WHERE cp.fk_product = t.fk_product";
$sqlCategoryProductNotExists .= " )";
$searchCategoryProductSqlList[] = $sqlCategoryProductNotExists;
} elseif (intval($searchCategoryProduct) > 0) {
$existsCategoryProductList[] = $db->escape($searchCategoryProduct);
}
}
if (!empty($existsCategoryProductList)) {
$sqlCategoryProductExists = " EXISTS (";
$sqlCategoryProductExists .= " SELECT cp.fk_product";
$sqlCategoryProductExists .= " FROM ".$db->prefix()."categorie_product AS cp";
$sqlCategoryProductExists .= " WHERE cp.fk_product = t.fk_product";
$sqlCategoryProductExists .= " AND cp.fk_categorie IN (".$db->sanitize(implode(',', $existsCategoryProductList)).")";
$sqlCategoryProductExists .= " )";
$searchCategoryProductSqlList[] = $sqlCategoryProductExists;
}
if (!empty($searchCategoryProductSqlList)) {
$sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")";
}
} else {
foreach ($searchCategoryProductList as $searchCategoryProduct) {
if (intval($searchCategoryProduct) == -2) {
$sqlCategoryProductNotExists = " NOT EXISTS (";
$sqlCategoryProductNotExists .= " SELECT cp.fk_product";
$sqlCategoryProductNotExists .= " FROM ".$db->prefix()."categorie_product AS cp";
$sqlCategoryProductNotExists .= " WHERE cp.fk_product = t.fk_product";
$sqlCategoryProductNotExists .= " )";
$searchCategoryProductSqlList[] = $sqlCategoryProductNotExists;
} elseif (intval($searchCategoryProduct) > 0) {
$searchCategoryProductSqlList[] = "t.fk_product IN (SELECT fk_product FROM ".$db->prefix()."categorie_product WHERE fk_categorie = ".((int) $searchCategoryProduct).")";
}
}
if (!empty($searchCategoryProductSqlList)) {
$sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")";
}
}
//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@ -348,6 +403,9 @@ foreach ($search as $key => $val) {
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
foreach ($searchCategoryProductList as $searchCategoryProduct) {
$param .= "&search_category_product_list[]=".urlencode($searchCategoryProduct);
}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// Add $param from hooks
@ -405,6 +463,19 @@ $moreforfilter = '';
$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
$moreforfilter.= '</div>';*/
// Filter on categories
if (!empty($conf->global->MAIN_SEARCH_CATEGORY_PRODUCT_ON_LISTS) && !empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->transnoentities('ProductsCategoriesShort');
$moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
$categoriesProductArr = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', '', 64, 0, 1);
$categoriesProductArr[-2] = '- '.$langs->trans('NotCategorized').' -';
$moreforfilter .= Form::multiselectarray('search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0, 'minwidth300', 0, 0, '', 'category', $tmptitle);
$moreforfilter .= ' <input type="checkbox" class="valignmiddle" id="search_category_product_operator" name="search_category_product_operator" value="1"'.($searchCategoryProductOperator == 1 ? ' checked="checked"' : '').'/>';
$moreforfilter .= $form->textwithpicto('', $langs->trans('UseOrOperatorForCategories') . ' : ' . $tmptitle, 1, 'help', '', 0, 2, 'tooltip_cat_pro'); // Tooltip on click
$moreforfilter .= '</div>';
}
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {

View File

@ -290,7 +290,7 @@ $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
llxHeader("", $title, $help_url);
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewWarehouse"), '', 'stock');
dol_set_focus('input[name="libelle"]');

View File

@ -378,7 +378,7 @@ llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("Batch"), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -413,7 +413,7 @@ print '});
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("StockTransfer")), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -806,7 +806,7 @@ if ($action == 'create' && $user->rights->projet->creer) {
if ($action == 'clone') {
$formquestion = array(
'text' => $langs->trans("ConfirmClone"),
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int') > 0 ?GETPOST('socid', 'int') : $object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200')),
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int') > 0 ?GETPOST('socid', 'int') : $object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200 maxwidth250')),
array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true),
array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true),
array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true),
@ -815,7 +815,7 @@ if ($action == 'create' && $user->rights->projet->creer) {
array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false)
);
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClone"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 300, 590);
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClone"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 400, 590);
}
@ -1293,7 +1293,7 @@ if ($action == 'create' && $user->rights->projet->creer) {
print dolGetButtonAction('', $langs->trans('ExportAccountingReportButtonLabel'), 'default', $url, '');
}
*/
// Modify
if ($object->statut != Project::STATUS_CLOSED && $user->rights->projet->creer) {
if ($userWrite > 0) {

View File

@ -127,6 +127,7 @@ class Task extends CommonObjectLine
public $timespent_fk_user;
public $timespent_thm;
public $timespent_note;
public $timespent_fk_product;
public $comments = array();
@ -1227,6 +1228,7 @@ class Task extends CommonObjectLine
$sql .= ", task_date_withhour";
$sql .= ", task_duration";
$sql .= ", fk_user";
$sql .= ", fk_product";
$sql .= ", note";
$sql .= ", datec";
$sql .= ") VALUES (";
@ -1236,6 +1238,7 @@ class Task extends CommonObjectLine
$sql .= ", ".(empty($this->timespent_withhour) ? 0 : 1);
$sql .= ", ".((int) $this->timespent_duration);
$sql .= ", ".((int) $this->timespent_fk_user);
$sql .= ", ".((int) $this->timespent_fk_product);
$sql .= ", ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null");
$sql .= ", '".$this->db->idate($now)."'";
$sql .= ")";
@ -1523,6 +1526,7 @@ class Task extends CommonObjectLine
$sql .= " t.task_date_withhour,";
$sql .= " t.task_duration,";
$sql .= " t.fk_user,";
$sql .= " t.fk_product,";
$sql .= " t.thm,";
$sql .= " t.note";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
@ -1541,6 +1545,7 @@ class Task extends CommonObjectLine
$this->timespent_withhour = $obj->task_date_withhour;
$this->timespent_duration = $obj->task_duration;
$this->timespent_fk_user = $obj->fk_user;
$this->timespent_fk_product = $obj->fk_product;
$this->timespent_thm = $obj->thm; // hourly rate
$this->timespent_note = $obj->note;
}
@ -1694,6 +1699,7 @@ class Task extends CommonObjectLine
$sql .= " task_date_withhour = ".(empty($this->timespent_withhour) ? 0 : 1).",";
$sql .= " task_duration = ".((int) $this->timespent_duration).",";
$sql .= " fk_user = ".((int) $this->timespent_fk_user).",";
$sql .= " fk_product = ".((int) $this->timespent_fk_product).",";
$sql .= " note = ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null");
$sql .= " WHERE rowid = ".((int) $this->timespent_id);

View File

@ -73,6 +73,7 @@ $search_task_ref = GETPOST('search_task_ref', 'alpha');
$search_task_label = GETPOST('search_task_label', 'alpha');
$search_user = GETPOST('search_user', 'int');
$search_valuebilled = GETPOST('search_valuebilled', 'int');
$search_product_ref = GETPOST('search_product_ref', 'alpha');
$search_company = GETPOST('$search_company', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
@ -166,6 +167,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_task_label = '';
$search_user = 0;
$search_valuebilled = '';
$search_product_ref = '';
$toselect = array();
$search_array_options = array();
$action = '';
@ -220,6 +222,7 @@ if ($action == 'addtimespent' && $user->rights->projet->time) {
$object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timemonth", 'int'), GETPOST("timeday", 'int'), GETPOST("timeyear", 'int'));
}
$object->timespent_fk_user = GETPOST("userid", 'int');
$object->timespent_fk_product = GETPOST("fk_product", 'int');
$result = $object->addTimeSpent($user);
if ($result >= 0) {
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
@ -271,17 +274,17 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us
$object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear"));
}
$object->timespent_fk_user = GETPOST("userid_line", 'int');
$object->timespent_fk_product = GETPOST("fk_product", 'int');
$result = 0;
if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
$result = $object->addTimeSpent($user);
}
if ($result >= 0) {
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans($object->error), null, 'errors');
$error++;
if ($result >= 0) {
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans($object->error), null, 'errors');
$error++;
}
}
} else {
$object->fetch($id, $ref);
@ -298,6 +301,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us
$object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth", 'int'), GETPOST("timelineday", 'int'), GETPOST("timelineyear", 'int'));
}
$object->timespent_fk_user = GETPOST("userid_line", 'int');
$object->timespent_fk_product = GETPOST("fk_product", 'int');
$result = 0;
if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) {
@ -391,36 +395,22 @@ if ($action == 'confirm_generateinvoice') {
$generateinvoicemode = GETPOST('generateinvoicemode', 'string');
$invoiceToUse = GETPOST('invoiceid', 'int');
$prodDurationHours = 1.0;
$prodDurationHoursBase = 1.0;
$product_data_cache = array();
if ($idprod > 0) {
$tmpproduct->fetch($idprod);
if ($result<0) {
$error++;
setEventMessages($tmpproduct->error, $tmpproduct->errors, 'errors');
}
if (empty($tmpproduct->duration_value)) {
$prodDurationHoursBase=$tmpproduct->getProductDurationHours();
if ($prodDurationHoursBase<0) {
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorDurationForServiceNotDefinedCantCalculateHourlyPrice"), null, 'errors');
setEventMessages(null, $tmpproduct->errors, 'errors');
}
if ($tmpproduct->duration_unit == 'i') {
$prodDurationHours = 1. / 60;
}
if ($tmpproduct->duration_unit == 'h') {
$prodDurationHours = 1.;
}
if ($tmpproduct->duration_unit == 'd') {
$prodDurationHours = 24.;
}
if ($tmpproduct->duration_unit == 'w') {
$prodDurationHours = 24. * 7;
}
if ($tmpproduct->duration_unit == 'm') {
$prodDurationHours = 24. * 30;
}
if ($tmpproduct->duration_unit == 'y') {
$prodDurationHours = 24. * 365;
}
$prodDurationHours *= $tmpproduct->duration_value;
$dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
$pu_ht = empty($dataforprice['pu_ht']) ? 0 : $dataforprice['pu_ht'];
@ -428,7 +418,7 @@ if ($action == 'confirm_generateinvoice') {
$localtax1 = $dataforprice['localtax1'];
$localtax2 = $dataforprice['localtax2'];
} else {
$prodDurationHours = 1;
$prodDurationHoursBase = 1;
$pu_ht = 0;
$txtva = get_default_tva($mysoc, $projectstatic->thirdparty);
@ -456,39 +446,85 @@ if ($action == 'confirm_generateinvoice') {
foreach ($toselect as $key => $value) {
// Get userid, timepent
$object->fetchTimeSpent($value);
$arrayoftasks[$object->timespent_fk_user]['timespent'] += $object->timespent_duration;
$arrayoftasks[$object->timespent_fk_user]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
$arrayoftasks[$object->timespent_fk_user][(int) $object->timespent_fk_product]['timespent'] += $object->timespent_duration;
$arrayoftasks[$object->timespent_fk_user][(int) $object->timespent_fk_product]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
}
foreach ($arrayoftasks as $userid => $value) {
foreach ($arrayoftasks as $userid => $data) {
$fuser->fetch($userid);
//$pu_ht = $value['timespent'] * $fuser->thm;
$username = $fuser->getFullName($langs);
foreach ($data as $fk_product=>$timespent_data) {
// Define qty per hour
$qtyhour = $timespent_data['timespent'] / 3600;
$qtyhourtext = convertSecondToTime($timespent_data['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
// Define qty per hour
$qtyhour = $value['timespent'] / 3600;
$qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
// If no unit price known
if (empty($pu_ht)) {
$pu_ht = price2num($timespent_data['totalvaluetodivideby3600'] / 3600, 'MU');
}
// If no unit price known
if (empty($pu_ht)) {
$pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU');
}
// Add lines
$prodDurationHours = $prodDurationHoursBase;
$idprodline=$idprod;
$pu_htline = $pu_ht;
$txtvaline = $txtva;
$localtax1line = $localtax1;
$localtax2line = $localtax2;
// Add lines
$lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
if (!empty($fk_product) && $fk_product!==$idprod) {
if (!array_key_exists($fk_product, $product_data_cache)) {
$result = $tmpproduct->fetch($fk_product);
if ($result < 0) {
$error++;
setEventMessages($tmpproduct->error, $tmpproduct->errors, 'errors');
}
$prodDurationHours = $tmpproduct->getProductDurationHours();
if ($prodDurationHours < 0) {
$error++;
$langs->load("errors");
setEventMessages(null, $tmpproduct->errors, 'errors');
}
// Update lineid into line of timespent
$sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id);
$sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid);
$result = $db->query($sql);
if (!$result) {
$error++;
setEventMessages($db->lasterror(), null, 'errors');
break;
$dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
$pu_htline = empty($dataforprice['pu_ht']) ? 0 : $dataforprice['pu_ht'];
$txtvaline = $dataforprice['tva_tx'];
$localtax1line = $dataforprice['localtax1'];
$localtax2line = $dataforprice['localtax2'];
$product_data_cache[$fk_product] = array('duration'=>$prodDurationHours,'dataforprice'=>$dataforprice);
} else {
$prodDurationHours = $product_data_cache[$fk_product]['duration'];
$pu_htline = empty($product_data_cache[$fk_product]['dataforprice']['pu_ht']) ? 0 : $product_data_cache[$fk_product]['dataforprice']['pu_ht'];
$txtvaline = $product_data_cache[$fk_product]['dataforprice']['tva_tx'];
$localtax1line = $product_data_cache[$fk_product]['dataforprice']['localtax1'];
$localtax2line = $product_data_cache[$fk_product]['dataforprice']['localtax2'];
}
$idprodline=$fk_product;
}
// Add lines
$lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0));
if ($lineid<0) {
$error++;
setEventMessages(null, $tmpinvoice->errors, 'errors');
}
// Update lineid into line of timespent
$sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id);
$sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid);
$result = $db->query($sql);
if (!$result) {
$error++;
setEventMessages($db->lasterror(), null, 'errors');
break;
}
}
}
} elseif ($generateinvoicemode == 'onelineperperiod') { // One line for each time spent line
$arrayoftasks = array();
$withdetail=GETPOST('detail_time_duration', 'alpha');
foreach ($toselect as $key => $value) {
// Get userid, timepent
@ -518,6 +554,7 @@ if ($action == 'confirm_generateinvoice') {
$arrayoftasks[$object->timespent_id]['note'] .= ' - '.$langs->trans("Duration").': '.convertSecondToTime($object->timespent_duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
}
$arrayoftasks[$object->timespent_id]['user'] = $object->timespent_fk_user;
$arrayoftasks[$object->timespent_id]['fk_product'] = $object->timespent_fk_product;
}
foreach ($arrayoftasks as $timespent_id => $value) {
@ -533,7 +570,49 @@ if ($action == 'confirm_generateinvoice') {
}
// Add lines
$lineid = $tmpinvoice->addline($value['note'], $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));
$prodDurationHours = $prodDurationHoursBase;
$idprodline=$idprod;
$pu_htline = $pu_ht;
$txtvaline = $txtva;
$localtax1line = $localtax1;
$localtax2line = $localtax2;
if (!empty($value['fk_product']) && $value['fk_product']!==$idprod) {
if (!array_key_exists($value['fk_product'], $product_data_cache)) {
$result = $tmpproduct->fetch($value['fk_product']);
if ($result < 0) {
$error++;
setEventMessages($tmpproduct->error, $tmpproduct->errors, 'errors');
}
$prodDurationHours = $tmpproduct->getProductDurationHours();
if ($prodDurationHours < 0) {
$error++;
$langs->load("errors");
setEventMessages(null, $tmpproduct->errors, 'errors');
}
$dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
$pu_htline = empty($dataforprice['pu_ht']) ? 0 : $dataforprice['pu_ht'];
$txtvaline = $dataforprice['tva_tx'];
$localtax1line = $dataforprice['localtax1'];
$localtax2line = $dataforprice['localtax2'];
$product_data_cache[$value['fk_product']] = array('duration'=>$prodDurationHours,'dataforprice'=>$dataforprice);
} else {
$prodDurationHours = $product_data_cache[$value['fk_product']]['duration'];
$pu_htline = empty($product_data_cache[$value['fk_product']]['dataforprice']['pu_ht']) ? 0 : $product_data_cache[$value['fk_product']]['dataforprice']['pu_ht'];
$txtvaline = $product_data_cache[$value['fk_product']]['dataforprice']['tva_tx'];
$localtax1line = $product_data_cache[$value['fk_product']]['dataforprice']['localtax1'];
$localtax2line = $product_data_cache[$value['fk_product']]['dataforprice']['localtax2'];
}
$idprodline=$value['fk_product'];
}
$lineid = $tmpinvoice->addline($value['note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0));
if ($lineid<0) {
$error++;
setEventMessages(null, $tmpinvoice->errors, 'errors');
}
//var_dump($lineid);exit;
// Update lineid into line of timespent
@ -552,56 +631,99 @@ if ($action == 'confirm_generateinvoice') {
// Get userid, timepent
$object->fetchTimeSpent($value); // Call method to get list of timespent for a timespent line id (We use the utiliy method found into Task object)
// $object->id is now the task id
$arrayoftasks[$object->id]['timespent'] += $object->timespent_duration;
$arrayoftasks[$object->id]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
$arrayoftasks[$object->id][(int) $object->timespent_fk_product]['timespent'] += $object->timespent_duration;
$arrayoftasks[$object->id][(int) $object->timespent_fk_product]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm);
}
foreach ($arrayoftasks as $task_id => $value) {
foreach ($arrayoftasks as $task_id => $data) {
$ftask = new Task($db);
$ftask->fetch($task_id);
// Define qty per hour
$qtyhour = $value['timespent'] / 3600;
$qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
if ($idprod > 0) {
// If a product is defined, we msut use the $prodDurationHours and $pu_ht of product (already set previously).
$pu_ht_for_task = $pu_ht;
// If we want to reuse the value of timespent (so use same price than cost price)
if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) {
$pu_ht_for_task = price2num($value['totalvaluetodivideby3600'] / $value['timespent'], 'MU') * $prodDurationHours;
foreach ($data as $fk_product=>$timespent_data) {
$qtyhour = $timespent_data['timespent'] / 3600;
$qtyhourtext = convertSecondToTime($timespent_data['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
// Add lines
$prodDurationHours = $prodDurationHoursBase;
$idprodline=$idprod;
$pu_htline = $pu_ht;
$txtvaline = $txtva;
$localtax1line = $localtax1;
$localtax2line = $localtax2;
if (!empty($fk_product) && $fk_product!==$idprod) {
if (!array_key_exists($fk_product, $product_data_cache)) {
$result = $tmpproduct->fetch($fk_product);
if ($result < 0) {
$error++;
setEventMessages($tmpproduct->error, $tmpproduct->errors, 'errors');
}
$prodDurationHours = $tmpproduct->getProductDurationHours();
if ($prodDurationHours < 0) {
$error++;
$langs->load("errors");
setEventMessages(null, $tmpproduct->errors, 'errors');
}
$dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0);
$pu_htline = empty($dataforprice['pu_ht']) ? 0 : $dataforprice['pu_ht'];
$txtvaline = $dataforprice['tva_tx'];
$localtax1line = $dataforprice['localtax1'];
$localtax2line = $dataforprice['localtax2'];
$product_data_cache[$fk_product] = array('duration'=>$prodDurationHours,'dataforprice'=>$dataforprice);
} else {
$prodDurationHours = $product_data_cache[$fk_product]['duration'];
$pu_htline = empty($product_data_cache[$fk_product]['dataforprice']['pu_ht']) ? 0 : $product_data_cache[$fk_product]['dataforprice']['pu_ht'];
$txtvaline = $product_data_cache[$fk_product]['dataforprice']['tva_tx'];
$localtax1line = $product_data_cache[$fk_product]['dataforprice']['localtax1'];
$localtax2line = $product_data_cache[$fk_product]['dataforprice']['localtax2'];
}
$idprodline=$fk_product;
}
$pa_ht = price2num($value['totalvaluetodivideby3600'] / $value['timespent'], 'MU') * $prodDurationHours;
} else {
// If not product used, we use the hour unit for duration and unit price.
$pu_ht_for_task = 0;
// If we want to reuse the value of timespent (so use same price than cost price)
if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) {
$pu_ht_for_task = price2num($value['totalvaluetodivideby3600'] / $value['timespent'], 'MU');
if ($idprodline > 0) {
// If a product is defined, we msut use the $prodDurationHours and $pu_ht of product (already set previously).
$pu_ht_for_task = $pu_htline;
// If we want to reuse the value of timespent (so use same price than cost price)
if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) {
$pu_ht_for_task = price2num($timespent_data['totalvaluetodivideby3600'] / $timespent_data['timespent'], 'MU') * $prodDurationHours;
}
$pa_ht = price2num($timespent_data['totalvaluetodivideby3600'] / $timespent_data['timespent'], 'MU') * $prodDurationHours;
} else {
// If not product used, we use the hour unit for duration and unit price.
$pu_ht_for_task = 0;
// If we want to reuse the value of timespent (so use same price than cost price)
if (!empty($conf->global->PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE)) {
$pu_ht_for_task = price2num($timespent_data['totalvaluetodivideby3600'] / $timespent_data['timespent'], 'MU');
}
$pa_ht = price2num($timespent_data['totalvaluetodivideby3600'] / $timespent_data['timespent'], 'MU');
}
$pa_ht = price2num($value['totalvaluetodivideby3600'] / $value['timespent'], 'MU');
}
// Add lines
$date_start = '';
$date_end = '';
$lineName = $ftask->ref.' - '.$ftask->label;
$lineid = $tmpinvoice->addline($lineName, $pu_ht_for_task, price2num($qtyhour / $prodDurationHours, 'MS'), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0), 0, $date_start, $date_end, 0, 0, '', 'HT', 0, 1, -1, 0, '', 0, 0, null, $pa_ht);
if ($lineid < 0) {
$error++;
setEventMessages($tmpinvoice->error, $tmpinvoice->errors, 'errors');
break;
}
if (!$error) {
// Update lineid into line of timespent
$sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id);
$sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).')';
$result = $db->query($sql);
if (!$result) {
// Add lines
$date_start = '';
$date_end = '';
$lineName = $ftask->ref . ' - ' . $ftask->label;
$lineid = $tmpinvoice->addline($lineName, $pu_ht_for_task, price2num($qtyhour / $prodDurationHours, 'MS'), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), 0, $date_start, $date_end, 0, 0, '', 'HT', 0, 1, -1, 0, '', 0, 0, null, $pa_ht);
if ($lineid < 0) {
$error++;
setEventMessages($db->lasterror(), null, 'errors');
setEventMessages($tmpinvoice->error, $tmpinvoice->errors, 'errors');
break;
}
if (!$error) {
// Update lineid into line of timespent
$sql = 'UPDATE ' . MAIN_DB_PREFIX . 'projet_task_time SET invoice_line_id = ' . ((int) $lineid) . ', invoice_id = ' . ((int) $tmpinvoice->id);
$sql .= ' WHERE rowid IN (' . $db->sanitize(join(',', $toselect)) . ')';
$result = $db->query($sql);
if (!$result) {
$error++;
setEventMessages($db->lasterror(), null, 'errors');
break;
}
}
}
}
}
@ -1085,6 +1207,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
$arrayfields['author'] = array('label'=>$langs->trans("By"), 'checked'=>1);
$arrayfields['t.note'] = array('label'=>$langs->trans("Note"), 'checked'=>1);
if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
$arrayfields['t.fk_product'] = array('label' => $langs->trans("Product"), 'checked' => 1);
}
$arrayfields['t.task_duration'] = array('label'=>$langs->trans("Duration"), 'checked'=>1);
$arrayfields['value'] = array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>(empty($conf->salaries->enabled) ? 0 : 1));
$arrayfields['valuebilled'] = array('label'=>$langs->trans("Billed"), 'checked'=>1, 'enabled'=>(((!empty($conf->global->PROJECT_HIDE_TASKS) || empty($conf->global->PROJECT_BILL_TIME_SPENT)) ? 0 : 1) && $projectstatic->usage_bill_time));
@ -1312,6 +1437,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$tasks = array();
$sql = "SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm,";
$sql .= " t.fk_product,";
$sql .= " pt.ref, pt.label, pt.fk_projet,";
$sql .= " u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,";
$sql .= " il.fk_facture as invoice_id, inv.fk_statut,";
@ -1324,9 +1450,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facturedet as il ON il.rowid = t.invoice_line_id";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as inv ON inv.rowid = il.fk_facture";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as prod ON prod.rowid = t.fk_product";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."projet_task as pt ON pt.rowid = t.fk_task";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON t.fk_user = u.rowid";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = pt.fk_projet";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON t.fk_user = u.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
// Add table from hooks
@ -1363,6 +1490,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($search_user > 0) {
$sql .= natural_search('t.fk_user', $search_user, 2);
}
if (!empty($search_product_ref)) {
$sql .= natural_search('prod.ref', $search_product_ref);
}
if ($search_valuebilled == '1') {
$sql .= ' AND t.invoice_id > 0';
}
@ -1461,6 +1591,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '<td>'.$langs->trans("ProgressDeclared").'</td>';
if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
print '<td></td>';
if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
print '<td>'.$langs->trans("Product").'</td>';
}
}
// Hook fields
$parameters = array('mode' => 'create');
@ -1536,6 +1670,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
print '<td>';
print '</td>';
if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
print '<td class="nowrap">';
print $form->select_produits('', 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 0, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500');
print '</td>';
}
}
// Fields from hook
@ -1619,6 +1759,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if (!empty($arrayfields['t.task_duration']['checked'])) {
print '<td class="liste_titre right"></td>';
}
// Product
if (!empty($arrayfields['t.fk_product']['checked'])) {
print '<td class="liste_titre right"></td>';
}
// Value in main currency
if (!empty($arrayfields['value']['checked'])) {
print '<td class="liste_titre"></td>';
@ -1670,6 +1814,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if (!empty($arrayfields['t.task_duration']['checked'])) {
print_liste_field_titre($arrayfields['t.task_duration']['label'], $_SERVER['PHP_SELF'], 't.task_duration', '', $param, '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['t.fk_product']['checked'])) {
print_liste_field_titre($arrayfields['t.fk_product']['label'], $_SERVER['PHP_SELF'], 't.fk_product', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['value']['checked'])) {
print_liste_field_titre($arrayfields['value']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
}
@ -1860,6 +2008,23 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$totalarray['totalduration'] += $task_time->task_duration;
}
//Product
if (!empty($arrayfields['t.fk_product']['checked'])) {
print '<td class="nowraponall">';
if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) {
$form->select_produits($task_time->fk_product, 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 0, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500');
} elseif (!empty($task_time->fk_product)) {
$product = new Product($db);
$resultFetch = $product->fetch($task_time->fk_product);
if ($resultFetch < 0) {
setEventMessages($product->error, $product->errors, 'errors');
} else {
print $product->getNomUrl(1);
}
}
print '</td>';
}
// Value spent
if (!empty($arrayfields['value']['checked'])) {
$langs->load("salaries");

View File

@ -728,7 +728,7 @@ if ($action == 'create2') {
}
// Mode creation.
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
$recept = new Reception($db);
print load_fiche_titre($langs->trans("CreateReception"));

View File

@ -864,6 +864,7 @@ class Reception extends CommonObject
$line->status = 1;
$line->cost_price = $cost_price;
$line->fk_reception = $this->id;
$this->lines[$num] = $line;
return $num;

View File

@ -283,7 +283,7 @@ llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("RecruitmentCandidature")), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -202,7 +202,7 @@ $help_url = '';
llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewPositionToBeFilled"), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -197,7 +197,7 @@ $form = new Form($db);
$formresource = new FormResource($db);
if ($action == 'create' || $object->fetch($id, $ref) > 0) {
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($title, '', 'object_resource');
print dol_get_fiche_head('');
} else {

View File

@ -457,7 +457,7 @@ if ($id > 0) {
}
// Create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
$year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;

View File

@ -51,19 +51,15 @@ $formcompany = new FormCompany($db);
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'setcodeclient') {
if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
} else {
$result = dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON", $value, 'chaine', 0, '', $conf->entity);
if ($result <= 0) {
dol_print_error($db);
}
}
if ($action == 'setcodecompta') {
if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
} else {
$result = dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON", $value, 'chaine', 0, '', $conf->entity);
if ($result <= 0) {
dol_print_error($db);
}
}
@ -273,10 +269,8 @@ if ($action == 'setprofid') {
$status = GETPOST('status', 'alpha');
$idprof = "SOCIETE_".$value."_UNIQUE";
if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) {
//header("Location: ".$_SERVER["PHP_SELF"]);
//exit;
} else {
$result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity);
if ($result <= 0) {
dol_print_error($db);
}
}
@ -286,10 +280,8 @@ if ($action == 'setprofidmandatory') {
$status = GETPOST('status', 'alpha');
$idprof = "SOCIETE_".$value."_MANDATORY";
if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) {
//header("Location: ".$_SERVER["PHP_SELF"]);
//exit;
} else {
$result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity);
if ($result <= 0) {
dol_print_error($db);
}
}
@ -299,10 +291,8 @@ if ($action == 'setprofidinvoicemandatory') {
$status = GETPOST('status', 'alpha');
$idprof = "SOCIETE_".$value."_INVOICE_MANDATORY";
if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) {
//header("Location: ".$_SERVER["PHP_SELF"]);
//exit;
} else {
$result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity);
if ($result <= 0) {
dol_print_error($db);
}
}
@ -311,10 +301,8 @@ if ($action == 'setprofidinvoicemandatory') {
if ($action == 'sethideinactivethirdparty') {
$status = GETPOST('status', 'alpha');
if (dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
} else {
$result = dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity);
if ($result <= 0) {
dol_print_error($db);
}
}
@ -331,6 +319,7 @@ if ($action == 'setonsearchandlistgooncustomerorsuppliercard') {
}
}
/*
* View
*/
@ -575,7 +564,7 @@ foreach ($dirsociete as $dirroot) {
if ($modulequalified) {
print '<tr class="oddeven"><td width="100">';
print $module->name;
print dol_escape_htmltag($module->name);
print "</td><td>\n";
if (method_exists($module, 'info')) {
print $module->info($langs);
@ -589,7 +578,7 @@ foreach ($dirsociete as $dirroot) {
print "<td class=\"center\">\n";
//if ($conf->global->COMPANY_ADDON_PDF != "$name")
//{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'&token='.newToken().'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'&token='.newToken().'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">';
print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>';
//}
@ -605,7 +594,7 @@ foreach ($dirsociete as $dirroot) {
print "</td>";
} else {
print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.urlencode($name).'&token='.newToken().'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.urlencode($name).'&token='.newToken().'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>";
}
}
@ -626,7 +615,7 @@ foreach ($dirsociete as $dirroot) {
// Preview
print '<td class="center nowrap">';
if ($module->type == 'pdf') {
$linkspec = '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&token='.newToken().'&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
$linkspec = '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=specimen&token='.newToken().'&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else {
$linkspec = img_object($langs->trans("PreviewNotAvailable"), 'generic');
}

View File

@ -981,7 +981,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// -----------------------------------------
// When used in standard mode
// -----------------------------------------
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
/*
* Creation
*/

View File

@ -1141,7 +1141,7 @@ if (!empty($conf->project->enabled)) {
$now = dol_now();
// Add new askprice
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
$currency_code = $conf->currency;
print load_fiche_titre($langs->trans("SupplierProposalNew"), '', 'supplier_proposal');

View File

@ -177,6 +177,7 @@ if (!empty($conf->multicurrency->enabled) && !empty($_SESSION["takeposcustomercu
}
}
/*
* Actions
*/
@ -278,7 +279,8 @@ if (empty($reshook)) {
$res = $invoice->validate($user);
if ($res < 0) {
$error++;
dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
$langs->load("admin");
dol_htmloutput_errors($invoice->error == 'NotConfigured' ? $langs->trans("NotConfigured").' (TakePos numbering module)': $invoice->error, $invoice->errors, 1);
}
}

View File

@ -259,7 +259,7 @@ $fuserstatic = new User($db);
$form = new Form($db);
$formfile = new FormFile($db);
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewGroup"), '', 'object_group');
dol_set_focus('#nom');

View File

@ -508,6 +508,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $
// Output page
// --------------------------------------------------------------------
$title = $langs->trans("ListOfUsers");
llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist');

View File

@ -272,7 +272,7 @@ if ($result > 0) {
print '</tr>';
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
// $listofemails=$object->thirdparty_and_contact_email_array();
if ($object->email) {
$actions = array();

View File

@ -158,7 +158,7 @@ $help_url = 'EN:Module_Products#Variants';
llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("ProductAttribute")), '', 'object_' . $object->picto);
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';

View File

@ -240,7 +240,7 @@ llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
if (empty($permissiontoadd)) {
accessforbidden($langs->trans('NotEnoughPermissions'), 0, 1);
exit;

View File

@ -118,7 +118,7 @@ $formfile = new FormFile($db);
llxHeader('', 'WebsiteAccount', '');
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("WebsiteAccount")));
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -186,7 +186,7 @@ llxHeader('', $title, $help_url);
<?php
// Part to create
if ($action == 'create') {
if ($action == 'create' || (empty($action) && empty($id))) {
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Workstation")), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -166,6 +166,7 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
print __METHOD__."\n";
}
/**
* testNum2Alpha
*
@ -535,6 +536,10 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
$input='This is a text with html comments <!-- comment -->'; // we suppose this is not enough to be html content
$after=dol_textishtml($input);
$this->assertFalse($after);
$input="A text\nwith a link https://aaa?param=abc&amp;param2=def";
$after=dol_textishtml($input);
$this->assertFalse($after);
}