';
- print ''.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->label_incoterms, 1).' ';
+ print ''.$form->textwithpicto($langs->trans("IncotermLabel"), !empty($objectsrc->label_incoterms) ? $objectsrc->label_incoterms : '', 1).' ';
print '';
$incoterm_id = GETPOST('incoterm_id');
$incoterm_location = GETPOST('location_incoterms');
@@ -3644,7 +3646,7 @@ if ($action == 'create') {
}
// Other attributes
- $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="2"', 'cols' => '2', 'socid'=>$socid);
+ $parameters = array('objectsrc' => !empty($objectsrc) ? $objectsrc : 0, 'colspan' => ' colspan="2"', 'cols' => '2', 'socid'=>$socid);
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook)) {
diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php
index 9619e1a9ddd..d785ccbce93 100644
--- a/htdocs/compta/facture/invoicetemplate_list.php
+++ b/htdocs/compta/facture/invoicetemplate_list.php
@@ -692,6 +692,10 @@ if ($resql) {
if ($num > 0) {
$i = 0;
$totalarray = array();
+ $totalarray['nbfield'] = 0;
+ $totalarray['val']['f.total_ht'] = 0;
+ $totalarray['val']['f.total_tva'] = 0;
+ $totalarray['val']['f.total_ttc'] = 0;
while ($i < min($num, $limit)) {
$objp = $db->fetch_object($resql);
if (empty($objp)) {
@@ -701,7 +705,7 @@ if ($resql) {
$companystatic->id = $objp->socid;
$companystatic->name = $objp->name;
- $invoicerectmp->id = $objp->id ? $objp->id : $objp->facid;
+ $invoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid;
$invoicerectmp->frequency = $objp->frequency;
$invoicerectmp->suspended = $objp->suspended;
$invoicerectmp->unit_frequency = $objp->unit_frequency;
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 52b2fcceee0..02ce893b96d 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -805,7 +805,7 @@ if (!$sall) {
}
}
// Add GroupBy from hooks
- $parameters = array('all' => $all, 'fieldstosearchall' => $fieldstosearchall);
+ $parameters = array('all' => !empty($all) ? $all : 0, 'fieldstosearchall' => $fieldstosearchall);
$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
} else {
@@ -1650,7 +1650,7 @@ if ($resql) {
$facturestatic->note_public = $obj->note_public;
$facturestatic->note_private = $obj->note_private;
- if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_WARRANTY) {
+ if (!empty($conf->global->INVOICE_USE_SITUATION) && !empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) {
$facturestatic->retained_warranty = $obj->retained_warranty;
$facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit;
$facturestatic->situation_final = $obj->retained_warranty_date_limit;
@@ -1846,8 +1846,8 @@ if ($resql) {
}
// Alias
if (!empty($arrayfields['s.name_alias']['checked'])) {
- print ' ';
- print dol_escape_htmltag($obj->name_alias);
+ print ' ';
+ print dol_escape_htmltag((!empty($obj->name_alias) ? $obj->name_alias : ''));
print ' ';
if (!$i) {
$totalarray['nbfield']++;
diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php
index babadfe7366..98337746090 100644
--- a/htdocs/compta/facture/stats/index.php
+++ b/htdocs/compta/facture/stats/index.php
@@ -102,7 +102,7 @@ if ($mode == 'customer') {
$stats->where .= ' AND f.fk_statut IN ('.$db->sanitize($object_status).')';
}
if (is_array($custcats) && !empty($custcats)) {
- $stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cat ON (f.fk_soc = cat.fk_soc)';
+ $stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cat OmdN (f.fk_soc = cat.fk_soc)';
$stats->where .= ' AND cat.fk_categorie IN ('.$db->sanitize(implode(',', $custcats)).')';
}
}
@@ -341,7 +341,7 @@ if (!in_array($nowyear, $arrayyears)) {
$arrayyears[$nowyear] = $nowyear;
}
arsort($arrayyears);
-print $form->selectarray('year', $arrayyears, $year, 0);
+print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75');
print ' ';
print '';
print ' 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$year.' ';
print ''.$val['nb'].' ';
- print ''.($val['nb_diff'] < 0 ? '' : '+').round($val['nb_diff']).'% ';
+ print ''.(!empty($val['nb_diff']) && $val['nb_diff'] < 0 ? '' : '+').round(!empty($val['nb_diff']) ? $val['nb_diff'] : 0).'% ';
print ''.price(price2num($val['total'], 'MT'), 1).' ';
- print ''.($val['total_diff'] < 0 ? '' : '+').round($val['total_diff']).'% ';
+ print ''.( !empty($val['total_diff']) && $val['total_diff'] < 0 ? '' : '+').round(!empty($val['total_diff']) ? $val['total_diff'] : 0).'% ';
print ''.price(price2num($val['avg'], 'MT'), 1).' ';
- print ''.($val['avg_diff'] < 0 ? '' : '+').round($val['avg_diff']).'% ';
+ print ''.(!empty($val['avg_diff']) && $val['avg_diff'] < 0 ? '' : '+').round(!empty($val['avg_diff']) ? $val['avg_diff'] : 0).'% ';
print ' ';
$oldyear = $year;
}
diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php
index 8207802feaa..98ebe32f970 100644
--- a/htdocs/compta/sociales/card.php
+++ b/htdocs/compta/sociales/card.php
@@ -26,11 +26,11 @@
*/
require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
@@ -46,8 +46,14 @@ if (!empty($conf->accounting->enabled)) {
$langs->loadLangs(array('compta', 'bills', 'banks', 'hrm'));
$id = GETPOST('id', 'int');
+$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
-$confirm = GETPOST('confirm');
+$confirm = GETPOST('confirm', 'alpha');
+$cancel = GETPOST('cancel', 'aZ09');
+$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search
+$backtopage = GETPOST('backtopage', 'alpha');
+$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
+
$fk_project = (GETPOST('fk_project') ? GETPOST('fk_project', 'int') : 0);
$dateech = dol_mktime(GETPOST('echhour'), GETPOST('echmin'), GETPOST('echsec'), GETPOST('echmonth'), GETPOST('echday'), GETPOST('echyear'));
@@ -56,11 +62,28 @@ $label = GETPOST('label', 'alpha');
$actioncode = GETPOST('actioncode');
$fk_user = GETPOST('userid', 'int');
+// Initialize technical objects
$object = new ChargeSociales($db);
+$extrafields = new ExtraFields($db);
+$diroutputmassaction = $conf->tax->dir_output.'/temp/massgeneration/'.$user->id;
+$hookmanager->initHooks(array('taxsocialcontributioncard', 'globalcard'));
+
+if (empty($action) && empty($id) && empty($ref)) {
+ $action = 'view';
+}
+
+// Load object
if ($id > 0) {
$object->fetch($id);
}
+$permissiontoread = $user->rights->tax->charges->lire;
+$permissiontoadd = $user->rights->tax->charges->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
+$permissiontodelete = $user->rights->tax->charges->supprimer || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
+$permissionnote = $user->rights->tax->charges->creer; // Used by the include of actions_setnotes.inc.php
+$permissiondellink = $user->rights->tax->charges->creer; // Used by the include of actions_dellink.inc.php
+$upload_dir = $conf->tax->multidir_output[isset($object->entity) ? $object->entity : 1];
+
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) {
@@ -74,6 +97,12 @@ $result = restrictedArea($user, 'tax', $object->id, 'chargesociales', 'charges')
* Actions
*/
+$parameters = array();
+$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');
+}
+
// Classify paid
if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm == 'yes') {
$object->fetch($id);
@@ -122,7 +151,7 @@ if ($action == 'setmode' && $user->rights->tax->charges->creer) {
}
}
-// bank account
+// Bank account
if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) {
$object->fetch($id);
$result = $object->setBankAccount(GETPOST('fk_account', 'int'));
@@ -151,7 +180,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') {
// Add social contribution
if ($action == 'add' && $user->rights->tax->charges->creer) {
- $amount = price2num(GETPOST('amount'), 'MT');
+ $amount = price2num(GETPOST('amount', 'alpha'), 'MT');
if (!$dateech) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors');
@@ -189,7 +218,7 @@ if ($action == 'add' && $user->rights->tax->charges->creer) {
if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->creer) {
- $amount = price2num(GETPOST('amount'), 'MT');
+ $amount = price2num(GETPOST('amount', 'alpha'), 'MT');
if (!$dateech) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors');
@@ -297,6 +326,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char
*/
$form = new Form($db);
+$formfile = new FormFile($db);
$formsocialcontrib = new FormSocialContrib($db);
$bankaccountstatic = new Account($db);
if (!empty($conf->projet->enabled)) {
@@ -308,7 +338,7 @@ $help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividen
llxHeader("", $title, $help_url);
-// Mode creation
+// Form to create a social contribution
if ($action == 'create') {
print load_fiche_titre($langs->trans("NewSocialContribution"));
@@ -411,11 +441,7 @@ if ($action == 'create') {
print '';
}
-/* *************************************************************************** */
-/* */
-/* Card Mode */
-/* */
-/* *************************************************************************** */
+// View mode
if ($id > 0) {
$object = new ChargeSociales($db);
$result = $object->fetch($id);
@@ -594,7 +620,7 @@ if ($id > 0) {
}
print '';
- // Bank Account
+ // Bank account
if (!empty($conf->banque->enabled)) {
print '';
print '';
@@ -614,6 +640,11 @@ if ($id > 0) {
print ' ';
}
+ // Other attributes
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+
print '
';
print '';
@@ -627,7 +658,7 @@ if ($id > 0) {
/*
* Payments
*/
- $sql = "SELECT p.rowid, p.num_paiement as num_payment, datep as dp, p.amount,";
+ $sql = "SELECT p.rowid, p.num_paiement as num_payment, p.datep as dp, p.amount,";
$sql .= " c.code as type_code,c.libelle as paiement_type,";
$sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.currency_code as bacurrency_code, ba.fk_accountancy_journal';
$sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p";
@@ -637,7 +668,7 @@ if ($id > 0) {
$sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql .= " WHERE p.fk_charge = ".((int) $id);
$sql .= " AND p.fk_charge = cs.rowid";
- $sql .= " AND cs.entity IN (".getEntity('tax').")";
+ $sql .= " AND cs.entity IN (".getEntity('sc').")";
$sql .= " ORDER BY dp DESC";
//print $sql;
@@ -735,22 +766,15 @@ if ($id > 0) {
print dol_get_fiche_end();
if ($action == 'edit') {
- print '';
- print ' ';
- print ' ';
- print ' ';
- print '
';
- }
+ print $form->buttonsSaveCancel();
- if ($action == 'edit') {
print "\n";
}
- /*
- * Actions buttons
- */
+ // Buttons for actions
+
if ($action != 'edit') {
print ''."\n";
@@ -788,6 +812,64 @@ if ($id > 0) {
print "
";
}
+
+
+ // Select mail models is same action as presend
+ if (GETPOST('modelselected')) {
+ $action = 'presend';
+ }
+
+ if ($action != 'presend') {
+ print '';
+ print '
'; // ancre
+
+ $includedocgeneration = 1;
+
+ // Documents
+ if ($includedocgeneration) {
+ $objref = dol_sanitizeFileName($object->ref);
+ $relativepath = $objref.'/'.$objref.'.pdf';
+ $filedir = $conf->tax->dir_output.'/'.$objref;
+ $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
+ //$genallowed = $user->rights->tax->charges->lire; // If you can read, you can build the PDF to read content
+ $genallowed = 0;
+ $delallowed = $user->rights->tax->charges->creer; // If you can create/edit, you can remove a file on card
+ print $formfile->showdocuments('tax', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
+ }
+
+ // Show links to link elements
+ //$linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject'));
+ //$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
+
+
+ print '
';
+
+ /*
+ $MAXEVENT = 10;
+
+ $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id);
+
+ // List of actions on element
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
+ $formactions = new FormActions($db);
+ $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
+ */
+
+ print '
';
+ }
+
+ //Select mail models is same action as presend
+ if (GETPOST('modelselected')) {
+ $action = 'presend';
+ }
+
+ // Presend form
+ $modelmail = 'sc';
+ $defaulttopic = 'InformationMessage';
+ $diroutput = $conf->tax->dir_output;
+ $trackid = 'sc'.$object->id;
+
+ include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
} else {
/* Social contribution not found */
dol_print_error('', $object->error);
diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php
index ef09cd5aabc..530d18d17f9 100755
--- a/htdocs/compta/tva/card.php
+++ b/htdocs/compta/tva/card.php
@@ -306,7 +306,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') {
}
if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->creer) {
- $amount = price2num(GETPOST('amount'));
+ $amount = price2num(GETPOST('amount', 'alpha'), 'MT');
if (empty($amount)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
@@ -317,7 +317,7 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->cr
} else {
$result = $object->fetch($id);
- $object->amount = price2num($amount);
+ $object->amount = $amount;
$result = $object->update($user);
if ($result <= 0) {
@@ -339,8 +339,8 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char
$object->fetch($id);
if ($object->id > 0) {
- $object->paye = 0;
$object->id = $object->ref = null;
+ $object->paye = 0;
if (GETPOST('clone_label', 'alphanohtml')) {
$object->label = GETPOST('clone_label', 'alphanohtml');
@@ -535,7 +535,7 @@ if ($action == 'create') {
}
// View mode
-if ($id) {
+if ($id > 0) {
$head = vat_prepare_head($object);
$totalpaye = $object->getSommePaiement();
@@ -705,7 +705,8 @@ if ($id) {
$objp = $db->fetch_object($resql);
print '