Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
ad5a350073
56
ChangeLog
56
ChangeLog
@ -7,7 +7,9 @@ For users:
|
||||
- New: [ task #877 ] Reorganize some menus.
|
||||
- New: [ task #858 ] Holiday module: note on manual holiday assignation.
|
||||
- New: Add graph of bank account input/output into input-output report page.
|
||||
|
||||
- New: Add script export-bank-receipts.
|
||||
- New: Add option "filter=bank" onto script rebuild_merge_pdf.php to merge
|
||||
PDF that has one payment on a specific bank account.
|
||||
For developers:
|
||||
- New: DolGraph can build graph with three lines.
|
||||
|
||||
@ -101,32 +103,32 @@ WARNING: If you used external modules, some of them may need to be upgraded due
|
||||
|
||||
***** ChangeLog for 3.3.2 compared to 3.3.1 *****
|
||||
|
||||
- Fix: Dutch (nl_NL) translation
|
||||
- Generalize fix: file with a specific mask not found, again
|
||||
- Fix: translations and BILL_SUPPLIER_BUILDDOC trigger
|
||||
- Fix: Can't reset payment due date
|
||||
- Fix: Orderstoinvoice didn't act as expected when no order was checked
|
||||
- Fix: Bad link to all proposals into Third party card if customer is prospect
|
||||
- Fix: Some bugs on withdrawal rejects
|
||||
- Fix: [ bug #774 ] Bug on creating event with box "all day" crossed
|
||||
- Fix: [ bug #787 ] Invoice supplier box incorrect tooltip when delay on payment
|
||||
- Fix: [ bug #789 ] VAT not being calculated in POS
|
||||
- Fix: [ bug #790 ] Spanish localtax RE not being correctly calculated
|
||||
- Fix: [ bug #794 ] Lost filter on zipcode in prospect list
|
||||
- Fix: [ bug #806 ] Margins module with orders2invoice does not respect cost price
|
||||
- Fix: [ bug #810 ] Cannot update ODT template path
|
||||
- Fix: [ bug #816 ] Sales journal does not reflect localtaxes
|
||||
- Fix: [ bug #817 ] Purchases journal does not reflect localtaxes
|
||||
- Fix: [ bug #824 ] MAIN_DB_PREFIX not use into dictionnary
|
||||
- Fix: [ bug #828 ] Error when code_region is not a number in llx_c_regions (with postgres)
|
||||
- Fix: [ bug #855 ] Holiday approval email in French
|
||||
- Fix: [ bug #856 ] (Holidays module) Mail error if destination user doesn't have an email
|
||||
- Fix: [ bug #857 ] Invoice created from shipment does not have the order discount
|
||||
- Fix: [ bug #861 ] Impossible to create a new event in agenda
|
||||
- Fix: [ bug #827 ] AJAX search does not respect multiprice level
|
||||
- Fix: [ bug #865 ] Dolibarr navigation array in project/task do not work
|
||||
- Fix: [ bug #866 ] Standing order from an invoice suggests invoice total amount instead of remaining to pay
|
||||
- Fix: [ bug #788 ] Date of linked interventions are not shown
|
||||
- Fix: Dutch (nl_NL) translation.
|
||||
- Generalize fix: file with a specific mask not found, again.
|
||||
- Fix: translations and BILL_SUPPLIER_BUILDDOC trigger.
|
||||
- Fix: Can't reset payment due date.
|
||||
- Fix: Orderstoinvoice didn't act as expected when no order was checked.
|
||||
- Fix: Bad link to all proposals into Third party card if customer is prospect.
|
||||
- Fix: Some bugs on withdrawal rejects.
|
||||
- Fix: [ bug #774 ] Bug on creating event with box "all day" crossed.
|
||||
- Fix: [ bug #787 ] Invoice supplier box incorrect tooltip when delay on payment.
|
||||
- Fix: [ bug #789 ] VAT not being calculated in POS.
|
||||
- Fix: [ bug #790 ] Spanish localtax RE not being correctly calculated.
|
||||
- Fix: [ bug #794 ] Lost filter on zipcode in prospect list.
|
||||
- Fix: [ bug #806 ] Margins module with orders2invoice does not respect cost price.
|
||||
- Fix: [ bug #810 ] Cannot update ODT template path.
|
||||
- Fix: [ bug #816 ] Sales journal does not reflect localtaxes.
|
||||
- Fix: [ bug #817 ] Purchases journal does not reflect localtaxes.
|
||||
- Fix: [ bug #824 ] MAIN_DB_PREFIX not use into dictionnary.
|
||||
- Fix: [ bug #828 ] Error when code_region is not a number in llx_c_regions (with postgres).
|
||||
- Fix: [ bug #855 ] Holiday approval email in French.
|
||||
- Fix: [ bug #856 ] (Holidays module) Mail error if destination user doesn't have an email.
|
||||
- Fix: [ bug #857 ] Invoice created from shipment does not have the order discount.
|
||||
- Fix: [ bug #861 ] Impossible to create a new event in agenda.
|
||||
- Fix: [ bug #827 ] AJAX search does not respect multiprice level.
|
||||
- Fix: [ bug #865 ] Dolibarr navigation array in project/task do not work.
|
||||
- Fix: [ bug #866 ] Standing order from an invoice suggests invoice total amount instead of remaining to pay.
|
||||
- Fix: [ bug #788 ] Date of linked interventions are not shown.
|
||||
|
||||
|
||||
***** ChangeLog for 3.3.1 compared to 3.3 *****
|
||||
|
||||
25
README-FR
25
README-FR
@ -78,30 +78,29 @@ IV - CE QUE DOLIBARR PEUT FAIRE
|
||||
-------------------------------
|
||||
|
||||
Modules principaux:
|
||||
- Annuaires des prospects et/ou client et/ou fournisseurs
|
||||
- Gestion de catalogue de produits et services
|
||||
- Gestion de stock
|
||||
- Gestion des comptes bancaires
|
||||
- Annuaires des prospects et/ou client et/ou fournisseurs
|
||||
- Annuaires des contacts
|
||||
- Gestion des actions/taches avec un agenda intégré (ou lien avec webcalendar)
|
||||
- Agenda partagé
|
||||
- Gestion des commandes
|
||||
- Gestion des propositions commerciales
|
||||
- Gestion de contrats de services
|
||||
- Gestion des devis, propositions commerciales
|
||||
- Gestion des factures clients et fournisseurs
|
||||
- Gestion de contrats de services
|
||||
- Gestion des paiements
|
||||
- Gestion des virements bancaires
|
||||
- Gestion des expéditions
|
||||
- GED (Gestion Electronique de Documents)
|
||||
- EMailings de masse
|
||||
- Réalisation de sondages
|
||||
- Point de vente/Caisse enregistreuse
|
||||
|
||||
Autres modules:
|
||||
- Gestion de la TVA NPR (non perçue récupérable - pour les utilisateurs français des DOM-TOM)
|
||||
- Gestion des adhérents d'association
|
||||
- Gestion des dons
|
||||
- Gestion de marque-pages
|
||||
- Agenda
|
||||
- Point de vente/Caisse enregistreuse
|
||||
- Fonctions d'EMailing de masses vers les clients, prospect ou utilisateurs Dolibarr
|
||||
- Gestion des promesses de dons
|
||||
- Gestion de la TVA NPR (non perçue récupérable - pour les utilisateurs français des DOM-TOM)
|
||||
- Rapports
|
||||
- Fonctions d'exports
|
||||
- Imports/Exports des données
|
||||
- Connectivité LDAP
|
||||
- Export PDF de tous les éléments (factures, propositions commerciales, commandes, bons expéditions, etc...)
|
||||
- De nombreuses autres fonctionnalités issues de modules officiels ou non (AWStats, Bittorrent, Gravatar, Google, Webcalendar...)
|
||||
@ -122,7 +121,7 @@ V - CE QUE DOLIBARR NE PEUT PAS FAIRE (TACHES A FAIRE)
|
||||
Voici un liste de fonctionnalites pas encore gérées par Dolibarr:
|
||||
- Pas de compta analytique (uniquement gestion de trésorerie).
|
||||
- Dolibarr ne gère qu'une seule monnaie à la fois (mono-devise).
|
||||
- Dolibarr ne gère en standard qu'une société/institution/association (mono-société). Pour en gérer plusieurs (comme vos filiales), il faut, soit faire plusieurs installations de Dolibarr, soit installer le module MultiCompany qui permet de gérer n société/institutions/associations dans une seule instance par une isolation logique des données.
|
||||
- Dolibarr ne gère en standard qu'une société/institution/association mère (mono-société). Pour en gérer plusieurs (comme vos filiales), il faut, soit faire plusieurs installations de Dolibarr, soit installer le module MultiCompany qui permet de gérer n société/institutions/associations dans une seule instance par une isolation logique des données.
|
||||
- Ne gère pas la double tva (Fédérale / provinciale) du canada.
|
||||
- Dolibarr ne contient pas de module de Gestion de la paie.
|
||||
- Les taches du module de gestion de projets n'ont pas de dépendance entre elle.
|
||||
|
||||
30
README.md
30
README.md
@ -75,33 +75,35 @@ See ChangeLog file found into package.
|
||||
|
||||
### Main modules/features:
|
||||
|
||||
- Products and services catalog
|
||||
- Customers, Prospects or Suppliers directory
|
||||
- Address book
|
||||
- Products and services catalog
|
||||
- Stock management
|
||||
- Bank accounts management
|
||||
- Orders management with PDF export
|
||||
- Commercial proposals management with PDF export
|
||||
- Commercial proposals management
|
||||
- Contracts management
|
||||
- Invoices management with PDF export
|
||||
- Invoices management
|
||||
- Payments management
|
||||
- Standing orders management
|
||||
- Shipping management
|
||||
- ECM (Electronic Content Management)
|
||||
- EMailings
|
||||
- Agenda with ical,vcal export for third tools integration
|
||||
- Management of foundation members
|
||||
- Donation management
|
||||
- ECM (Electronic Content Management)
|
||||
- Foundations members management
|
||||
- Employee's holidays management
|
||||
- Mass emailing
|
||||
- Realize surveys
|
||||
- Point of Sale
|
||||
|
||||
### Other modules:
|
||||
|
||||
- Bookmarks management
|
||||
- Can reports Dolibarr events inside Webcalendar or Phenix
|
||||
- Data export tools
|
||||
- Donations management
|
||||
- Reporting
|
||||
- Data export/import tools
|
||||
- LDAP connectivity
|
||||
- Third parties or products categories
|
||||
- ClickToDial phone numbers
|
||||
- RSS
|
||||
- RSS integration
|
||||
|
||||
### Miscellaneous:
|
||||
|
||||
@ -123,11 +125,11 @@ See ChangeLog file found into package.
|
||||
|
||||
This is features that Dolibarr does not support completely yet:
|
||||
|
||||
- No accountancy (only bank management).
|
||||
- No double party accountancy (only bank management).
|
||||
- Dolibarr manage one currency at once (mono-currency).
|
||||
- Dolibarr manage one company/foundation (mono-company). If you want to manage several companies or foundations, you must install several time the software (on same server or not). Another solution is to extend Dolibarr with the addon Module MultiCompany that allows to manage several companies in one Dolibarr instance (one database but with a logical isolation of datas).
|
||||
- Dolibarr manage one master company/foundation (mono-company). If you want to manage several companies or foundations, you must install several time the software (on same server or not). Another solution is to extend Dolibarr with the addon Module MultiCompany that allows to manage several companies in one Dolibarr instance (one database but with a logical isolation of datas).
|
||||
- Does not support double VAT (Federal / provincial) for Canada.
|
||||
- Dolibarr does not contains Payroll module.
|
||||
- Tasks on module project can't have dependencies between each other.
|
||||
- Dolibarr does not include any Webmail.
|
||||
- Dolibarr can't do coffee (not yet).
|
||||
- Dolibarr can't do coffee (not yet).
|
||||
|
||||
@ -68,7 +68,6 @@ if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL'
|
||||
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", '','chaine',0,'',$conf->entity);
|
||||
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", '','chaine',0,'',$conf->entity);
|
||||
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", '','chaine',0,'',$conf->entity);
|
||||
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_DELETE_INVOICE", '','chaine',0,'',$conf->entity);
|
||||
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_BILL','alpha'),'chaine',0,'',$conf->entity);
|
||||
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER','alpha'),'chaine',0,'',$conf->entity);
|
||||
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER','alpha'),'chaine',0,'',$conf->entity);
|
||||
@ -241,19 +240,6 @@ if (! empty($conf->fournisseur->enabled))
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||
print "</form>\n</td>\n</tr>\n";
|
||||
}
|
||||
if (! empty($conf->facture->enabled))
|
||||
{
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td width="60%">'.$langs->trans("ReStockOnDeleteInvoice").'</td>';
|
||||
print '<td width="160" align="right">';
|
||||
print "<form method=\"post\" action=\"stock.php\">";
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print "<input type=\"hidden\" name=\"action\" value=\"STOCK_CALCULATE_ON_DELETE_INVOICE\">";
|
||||
print $form->selectyesno("STOCK_CALCULATE_ON_DELETE_INVOICE",$conf->global->STOCK_CALCULATE_ON_DELETE_INVOICE,1);
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||
print "</form>\n</td>\n</tr>\n";
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
@ -932,7 +932,7 @@ if ($id > 0)
|
||||
|
||||
// Busy
|
||||
print '<tr><td class="nowrap">'.$langs->trans("Busy").'</td><td colspan="3">';
|
||||
print yn(($act->transparency > 0)?1:0);
|
||||
if ($act->usertodo->id > 0) print yn(($act->transparency > 0)?1:0); // We show nothing if event is assigned to nobody
|
||||
print '</td></tr>';
|
||||
|
||||
// Done by
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -277,8 +277,8 @@ else
|
||||
$sql.= " AND b.fk_account = ba.rowid";
|
||||
$sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day
|
||||
|
||||
dol_syslog("sql=".$sql);
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$var=True;
|
||||
|
||||
@ -35,6 +35,7 @@ class ChargeSociales extends CommonObject
|
||||
public $table_element='chargesociales';
|
||||
|
||||
var $id;
|
||||
var $ref;
|
||||
var $date_ech;
|
||||
var $lib;
|
||||
var $type;
|
||||
|
||||
@ -31,7 +31,8 @@ $langs->load("compta");
|
||||
$langs->load("banks");
|
||||
$langs->load("bills");
|
||||
|
||||
$id=$_REQUEST["id"];
|
||||
$id=GETPOST("id");
|
||||
$action=GETPOST('action');
|
||||
|
||||
$mesg = '';
|
||||
|
||||
@ -40,17 +41,25 @@ $socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||
|
||||
$tva = new Tva($db);
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('taxvatcard'));
|
||||
|
||||
|
||||
/**
|
||||
* Action ajout paiement tva
|
||||
*/
|
||||
if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
{
|
||||
$tva = new Tva($db);
|
||||
|
||||
/**
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($_POST["cancel"] == $langs->trans("Cancel"))
|
||||
{
|
||||
header("Location: reglement.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
|
||||
@ -74,13 +83,12 @@ if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
{
|
||||
$db->rollback();
|
||||
$mesg='<div class="error">'.$tva->error.'</div>';
|
||||
$_GET["action"]="create";
|
||||
$action="create";
|
||||
}
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'delete')
|
||||
if ($action == 'delete')
|
||||
{
|
||||
$tva = new Tva($db);
|
||||
$result=$tva->fetch($_GET['id']);
|
||||
|
||||
if ($tva->rappro == 0)
|
||||
@ -143,7 +151,7 @@ if ($id)
|
||||
}
|
||||
|
||||
// Formulaire saisie tva
|
||||
if ($_GET["action"] == 'create')
|
||||
if ($action == 'create')
|
||||
{
|
||||
print "<form name='add' action=\"fiche.php\" method=\"post\">\n";
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
@ -223,6 +231,9 @@ if ($id)
|
||||
print $vatpayment->ref;
|
||||
print '</td></tr>';
|
||||
|
||||
// Label
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$vatpayment->label.'</td></tr>';
|
||||
|
||||
print "<tr>";
|
||||
print '<td>'.$langs->trans("DatePayment").'</td><td colspan="3">';
|
||||
print dol_print_date($vatpayment->datep,'day');
|
||||
@ -273,5 +284,4 @@ if ($id)
|
||||
$db->close();
|
||||
|
||||
llxFooter();
|
||||
|
||||
?>
|
||||
?>
|
||||
@ -46,7 +46,7 @@ function societe_prepare_head($object)
|
||||
if ($object->client==1 || $object->client==2 || $object->client==3)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$object->id;
|
||||
$head[$h][1]='';
|
||||
$head[$h][1] = '';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && ($object->client==2 || $object->client==3)) $head[$h][1] .= $langs->trans("Prospect");
|
||||
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && $object->client==3) $head[$h][1] .= '/';
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && ($object->client==1 || $object->client==3)) $head[$h][1] .= $langs->trans("Customer");
|
||||
@ -60,7 +60,7 @@ function societe_prepare_head($object)
|
||||
$head[$h][2] = 'supplier';
|
||||
$h++;
|
||||
}
|
||||
if (! empty($conf->agenda->enabled))
|
||||
if (! empty($conf->agenda->enabled) && !empty($user->right->agenda->lire))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Agenda");
|
||||
@ -68,7 +68,7 @@ function societe_prepare_head($object)
|
||||
$h++;
|
||||
}
|
||||
//show categorie tab
|
||||
if (! empty($conf->categorie->enabled))
|
||||
if (! empty($conf->categorie->enabled) && !empty($user->right->categorie->lire))
|
||||
{
|
||||
$type = 2;
|
||||
if ($object->fournisseur) $type = 1;
|
||||
|
||||
@ -3323,7 +3323,7 @@ function picto_required()
|
||||
*
|
||||
* @param string $StringHtml String to clean
|
||||
* @param string $removelinefeed Replace also all lines feeds by a space
|
||||
* @param string $pagecodeto Encoding of input string
|
||||
* @param string $pagecodeto Encoding of input/output string
|
||||
* @return string String cleaned
|
||||
*/
|
||||
function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8')
|
||||
|
||||
@ -42,9 +42,10 @@ require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php');
|
||||
* @param int $usestdout Add information onto standard output
|
||||
* @param int $regenerate ''=Use existing PDF files, 'nameofpdf'=Regenerate all PDF files using the template
|
||||
* @param string $option Suffix to add into file name of generated PDF
|
||||
* @param string $paymentbankid Only if payment on this bank account id
|
||||
* @return int Error code
|
||||
*/
|
||||
function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate=0, $option='')
|
||||
function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate=0, $option='', $paymentbankid='')
|
||||
{
|
||||
$sql = "SELECT DISTINCT f.rowid, f.facnumber";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
@ -71,17 +72,25 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte
|
||||
$sqlwhere.= " f.fk_statut > 0";
|
||||
$sqlwhere.= " AND pf.fk_paiement IS NULL";
|
||||
}
|
||||
if (in_array('payments',$filter))
|
||||
if (in_array('payments',$filter) || in_array('bank',$filter))
|
||||
{
|
||||
$sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."paiement as p";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
|
||||
if (in_array('bank',$filter)) $sql.= ", ".MAIN_DB_PREFIX."bank as b";
|
||||
if (empty($sqlwhere)) $sqlwhere=' WHERE ';
|
||||
else $sqlwhere.=" AND";
|
||||
$sqlwhere.= " f.fk_statut > 0";
|
||||
$sqlwhere.= " AND f.rowid = pf.fk_facture";
|
||||
$sqlwhere.= " AND pf.fk_paiement = p.rowid";
|
||||
$sqlwhere.= " AND p.datep >= '".$db->idate($paymentdateafter)."'";
|
||||
$sqlwhere.= " AND p.datep <= '".$db->idate($paymentdatebefore)."'";
|
||||
if (in_array('payments',$filter))
|
||||
{
|
||||
$sqlwhere.= " AND p.datep >= '".$db->idate($paymentdateafter)."'";
|
||||
$sqlwhere.= " AND p.datep <= '".$db->idate($paymentdatebefore)."'";
|
||||
}
|
||||
if (in_array('bank',$filter))
|
||||
{
|
||||
$sqlwhere.= " AND p.fk_bank = b.rowid";
|
||||
$sqlwhere.= " AND b.fk_account = ".$paymentbankid;
|
||||
}
|
||||
$sqlorder = " ORDER BY p.datep ASC";
|
||||
}
|
||||
if (in_array('nodeposit',$filter))
|
||||
|
||||
@ -187,9 +187,10 @@ class ExportCsv extends ModeleExports
|
||||
* @param array $array_export_fields_label Array with list of label of fields
|
||||
* @param array $array_selected_sorted Array with list of field to export
|
||||
* @param Translate $outputlangs Object lang to translate values
|
||||
* @param array $array_types Array with types of fields
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs)
|
||||
function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -204,7 +205,7 @@ class ExportCsv extends ModeleExports
|
||||
|
||||
foreach($array_selected_sorted as $code => $value)
|
||||
{
|
||||
$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);
|
||||
$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]); // newvalue is now $outputlangs->charset_output encoded
|
||||
$newvalue=$this->csv_clean($newvalue,$outputlangs->charset_output);
|
||||
|
||||
fwrite($this->handle,$newvalue.$this->separator);
|
||||
@ -242,15 +243,12 @@ class ExportCsv extends ModeleExports
|
||||
if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-'),'_',$code);
|
||||
else $alias=substr($code, strpos($code, ' as ') + 4);
|
||||
if (empty($alias)) dol_print_error('','Bad value for field with key='.$code.'. Try to redefine export.');
|
||||
|
||||
$newvalue=$outputlangs->convToOutputCharset($objp->$alias);
|
||||
|
||||
$newvalue=$outputlangs->convToOutputCharset($objp->$alias); // objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded
|
||||
$typefield=isset($array_types[$code])?$array_types[$code]:'';
|
||||
|
||||
|
||||
// Translation newvalue
|
||||
if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
|
||||
{
|
||||
$newvalue=$outputlangs->transnoentities($reg[1]);
|
||||
}
|
||||
if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
|
||||
|
||||
$newvalue=$this->csv_clean($newvalue,$outputlangs->charset_output);
|
||||
|
||||
@ -284,11 +282,12 @@ class ExportCsv extends ModeleExports
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clean a cell to respect rules of CSV file cells
|
||||
*
|
||||
* @param string $newvalue String to clean
|
||||
* @param string $charset Output character set
|
||||
* @param string $charset Input AND Output character set
|
||||
* @return string Value cleaned
|
||||
*/
|
||||
function csv_clean($newvalue, $charset)
|
||||
@ -296,7 +295,9 @@ class ExportCsv extends ModeleExports
|
||||
$addquote=0;
|
||||
|
||||
// Rule Dolibarr: No HTML
|
||||
//print $charset.' '.$newvalue."\n";
|
||||
$newvalue=dol_string_nohtmltag($newvalue,1,$charset);
|
||||
//print $charset.' '.$newvalue."\n";
|
||||
|
||||
// Rule 1 CSV: No CR, LF in cells
|
||||
$newvalue=str_replace("\r",'',$newvalue);
|
||||
|
||||
@ -158,7 +158,7 @@ class ExportExcel extends ModeleExports
|
||||
$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
|
||||
}
|
||||
|
||||
dol_syslog("ExportExcel::open_file file=".$file);
|
||||
dol_syslog(get_class($this)."::open_file file=".$file);
|
||||
$this->file=$file;
|
||||
|
||||
$ret=1;
|
||||
@ -187,7 +187,7 @@ class ExportExcel extends ModeleExports
|
||||
|
||||
$this->workbook->setActiveSheetIndex(0);
|
||||
$this->workbook->getActiveSheet()->setTitle($outputlangs->trans("Sheet"));
|
||||
$this->workbook->getActiveSheet()->getDefaultRowDimension()->setRowHeight(15);
|
||||
$this->workbook->getActiveSheet()->getDefaultRowDimension()->setRowHeight(16);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
@ -212,9 +212,10 @@ class ExportExcel extends ModeleExports
|
||||
* @param array $array_export_fields_label Array with list of label of fields
|
||||
* @param array $array_selected_sorted Array with list of field to export
|
||||
* @param Translate $outputlangs Object lang to translate values
|
||||
* @param array $array_types Array with types of fields
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs)
|
||||
function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
|
||||
{
|
||||
// Create a format for the column headings
|
||||
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
|
||||
@ -231,7 +232,7 @@ class ExportExcel extends ModeleExports
|
||||
else
|
||||
{
|
||||
$this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true);
|
||||
$this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
||||
$this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
|
||||
}
|
||||
|
||||
$this->col=0;
|
||||
@ -247,6 +248,10 @@ class ExportExcel extends ModeleExports
|
||||
else
|
||||
{
|
||||
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $outputlangs->transnoentities($alias));
|
||||
if (! empty($array_types[$code]) && in_array($array_types[$code],array('Date','Number','TextAuto'))) // Set autowidth for some types
|
||||
{
|
||||
$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($this->col + 1))->setAutoSize(true);
|
||||
}
|
||||
}
|
||||
$this->col++;
|
||||
}
|
||||
@ -341,18 +346,17 @@ class ExportExcel extends ModeleExports
|
||||
$this->worksheet->write($this->row, $this->col, $newvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($typefield == 'Text')
|
||||
{
|
||||
if ($typefield == 'Text' || $typefield == 'TextAuto')
|
||||
{
|
||||
//$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue);
|
||||
$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
|
||||
$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
|
||||
$this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
|
||||
}
|
||||
else
|
||||
{
|
||||
//$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
|
||||
//if ($typefield == 'Text') $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
|
||||
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
|
||||
}
|
||||
}
|
||||
@ -412,6 +416,29 @@ class ExportExcel extends ModeleExports
|
||||
|
||||
return $newvalue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a column to letter (1->A, 0->B, 27->AA, ...)
|
||||
*
|
||||
* @param int $c Column position
|
||||
* @return string Letter
|
||||
*/
|
||||
function column2Letter($c)
|
||||
{
|
||||
|
||||
$c = intval($c);
|
||||
if ($c <= 0) return '';
|
||||
|
||||
while ($c != 0)
|
||||
{
|
||||
$p = ($c - 1) % 26;
|
||||
$c = intval(($c - $p) / 26);
|
||||
$letter = chr(65 + $p) . $letter;
|
||||
}
|
||||
|
||||
return $letter;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -72,310 +72,6 @@ class ExportExcel2007 extends ExportExcel
|
||||
$this->row=0;
|
||||
}
|
||||
|
||||
/**
|
||||
* getDriverLabel
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function getDriverId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* getDriverLabel
|
||||
*
|
||||
* @return string Return driver label
|
||||
*/
|
||||
function getDriverLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* getDriverDesc
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getDriverDesc()
|
||||
{
|
||||
return $this->desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* getDriverExtension
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getDriverExtension()
|
||||
{
|
||||
return $this->extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* getDriverVersion
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getDriverVersion()
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* getLibLabel
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getLibLabel()
|
||||
{
|
||||
return $this->label_lib;
|
||||
}
|
||||
|
||||
/**
|
||||
* getLibVersion
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getLibVersion()
|
||||
{
|
||||
return $this->version_lib;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open output file
|
||||
*
|
||||
* @param string $file File name to generate
|
||||
* @param Translate $outputlangs Output language object
|
||||
* @return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
function open_file($file,$outputlangs)
|
||||
{
|
||||
global $user,$conf,$langs;
|
||||
|
||||
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
|
||||
{
|
||||
$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
|
||||
}
|
||||
|
||||
dol_syslog("ExportExcel::open_file file=".$file);
|
||||
$this->file=$file;
|
||||
|
||||
$ret=1;
|
||||
|
||||
$outputlangs->load("exports");
|
||||
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
|
||||
{
|
||||
require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
|
||||
require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
|
||||
require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
|
||||
$this->workbook = new writeexcel_workbookbig($file);
|
||||
$this->workbook->set_tempdir($conf->export->dir_temp); // Set temporary directory
|
||||
$this->workbook->set_sheetname($outputlangs->trans("Sheet"));
|
||||
$this->worksheet = &$this->workbook->addworksheet();
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once PHPEXCEL_PATH.'PHPExcel.php';
|
||||
require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
|
||||
$this->workbook = new PHPExcel();
|
||||
$this->workbook->getProperties()->setCreator($user->getFullName($outputlangs).' - Dolibarr '.DOL_VERSION);
|
||||
//$this->workbook->getProperties()->setLastModifiedBy('Dolibarr '.DOL_VERSION);
|
||||
$this->workbook->getProperties()->setTitle($outputlangs->trans("Export").' - '.$file);
|
||||
$this->workbook->getProperties()->setSubject($outputlangs->trans("Export").' - '.$file);
|
||||
$this->workbook->getProperties()->setDescription($outputlangs->trans("Export").' - '.$file);
|
||||
|
||||
$this->workbook->setActiveSheetIndex(0);
|
||||
$this->workbook->getActiveSheet()->setTitle($outputlangs->trans("Sheet"));
|
||||
$this->workbook->getActiveSheet()->getDefaultRowDimension()->setRowHeight(16);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write header
|
||||
*
|
||||
* @param Translate $outputlangs Object lang to translate values
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function write_header($outputlangs)
|
||||
{
|
||||
//$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Output title line into file
|
||||
*
|
||||
* @param array $array_export_fields_label Array with list of label of fields
|
||||
* @param array $array_selected_sorted Array with list of field to export
|
||||
* @param Translate $outputlangs Object lang to translate values
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs)
|
||||
{
|
||||
// Create a format for the column headings
|
||||
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
|
||||
{
|
||||
$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
|
||||
|
||||
$formatheader =$this->workbook->addformat();
|
||||
$formatheader->set_bold();
|
||||
$formatheader->set_color('blue');
|
||||
//$formatheader->set_size(12);
|
||||
//$formatheader->set_font("Courier New");
|
||||
//$formatheader->set_align('center');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true);
|
||||
$this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
||||
}
|
||||
|
||||
$this->col=0;
|
||||
foreach($array_selected_sorted as $code => $value)
|
||||
{
|
||||
$alias=$array_export_fields_label[$code];
|
||||
//print "dd".$alias;
|
||||
if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
|
||||
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
|
||||
{
|
||||
$this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $outputlangs->transnoentities($alias));
|
||||
}
|
||||
$this->col++;
|
||||
}
|
||||
$this->row++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output record line into file
|
||||
*
|
||||
* @param array $array_selected_sorted Array with list of field to export
|
||||
* @param resource $objp A record from a fetch with all fields from select
|
||||
* @param Translate $outputlangs Object lang to translate values
|
||||
* @param array $array_types Array with types of fields
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
|
||||
{
|
||||
// Create a format for the column headings
|
||||
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
|
||||
{
|
||||
$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
|
||||
}
|
||||
|
||||
// Define first row
|
||||
$this->col=0;
|
||||
|
||||
foreach($array_selected_sorted as $code => $value)
|
||||
{
|
||||
if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-'),'_',$code);
|
||||
else $alias=substr($code, strpos($code, ' as ') + 4);
|
||||
if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
|
||||
$newvalue=$objp->$alias;
|
||||
|
||||
$newvalue=$this->excel_clean($newvalue);
|
||||
$typefield=isset($array_types[$code])?$array_types[$code]:'';
|
||||
|
||||
// Traduction newvalue
|
||||
if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
|
||||
{
|
||||
$newvalue=$outputlangs->transnoentities($reg[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$newvalue=$outputlangs->convToOutputCharset($newvalue);
|
||||
}
|
||||
|
||||
//var_dump($code.' '.$alias.' '.$newvalue.' '.$typefield);
|
||||
|
||||
if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i',$newvalue))
|
||||
{
|
||||
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
|
||||
{
|
||||
$formatdate=$this->workbook->addformat();
|
||||
$formatdate->set_num_format('yyyy-mm-dd');
|
||||
//$formatdate->set_num_format(0x0f);
|
||||
$arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
|
||||
//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
|
||||
$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later
|
||||
$this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate));
|
||||
}
|
||||
else
|
||||
{
|
||||
$newvalue=dol_stringtotime($newvalue);
|
||||
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
|
||||
$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
|
||||
$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
|
||||
}
|
||||
}
|
||||
elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i',$newvalue))
|
||||
{
|
||||
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
|
||||
{
|
||||
$formatdatehour=$this->workbook->addformat();
|
||||
$formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss');
|
||||
//$formatdatehour->set_num_format(0x0f);
|
||||
$arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
|
||||
//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
|
||||
$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later
|
||||
$this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
|
||||
}
|
||||
else
|
||||
{
|
||||
$newvalue=dol_stringtotime($newvalue);
|
||||
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
|
||||
$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
|
||||
$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
|
||||
{
|
||||
$this->worksheet->write($this->row, $this->col, $newvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($typefield == 'Text')
|
||||
{
|
||||
//$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue);
|
||||
$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
|
||||
$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->col++;
|
||||
}
|
||||
$this->row++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write footer
|
||||
*
|
||||
* @param Translate $outputlangs Output language object
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function write_footer($outputlangs)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close Excel file
|
||||
@ -399,20 +95,6 @@ class ExportExcel2007 extends ExportExcel
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clean a cell to respect rules of Excel file cells
|
||||
*
|
||||
* @param string $newvalue String to clean
|
||||
* @return string Value cleaned
|
||||
*/
|
||||
function excel_clean($newvalue)
|
||||
{
|
||||
// Rule Dolibarr: No HTML
|
||||
$newvalue=dol_string_nohtmltag($newvalue);
|
||||
|
||||
return $newvalue;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -182,13 +182,14 @@ class ExportTsv extends ModeleExports
|
||||
* @param array $array_export_fields_label Array with list of label of fields
|
||||
* @param array $array_selected_sorted Array with list of field to export
|
||||
* @param Translate $outputlangs Object lang to translate values
|
||||
* @param array $array_types Array with types of fields
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs)
|
||||
function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
|
||||
{
|
||||
foreach($array_selected_sorted as $code => $value)
|
||||
{
|
||||
$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);
|
||||
$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]); // newvalue is now $outputlangs->charset_output encoded
|
||||
$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
|
||||
|
||||
fwrite($this->handle,$newvalue.$this->separator);
|
||||
@ -218,14 +219,11 @@ class ExportTsv extends ModeleExports
|
||||
else $alias=substr($code, strpos($code, ' as ') + 4);
|
||||
if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
|
||||
|
||||
$newvalue=$outputlangs->convToOutputCharset($objp->$alias);
|
||||
$newvalue=$outputlangs->convToOutputCharset($objp->$alias); // objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded
|
||||
$typefield=isset($array_types[$code])?$array_types[$code]:'';
|
||||
|
||||
// Translation newvalue
|
||||
if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
|
||||
{
|
||||
$newvalue=$outputlangs->transnoentities($reg[1]);
|
||||
}
|
||||
if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
|
||||
|
||||
$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
|
||||
|
||||
@ -262,7 +260,7 @@ class ExportTsv extends ModeleExports
|
||||
* Clean a cell to respect rules of TSV file cells
|
||||
*
|
||||
* @param string $newvalue String to clean
|
||||
* @param string $charset Output character set
|
||||
* @param string $charset Input AND Output character set
|
||||
* @return string Value cleaned
|
||||
*/
|
||||
function tsv_clean($newvalue, $charset)
|
||||
|
||||
@ -520,7 +520,7 @@ class Export
|
||||
$objmodel->write_header($outputlangs);
|
||||
|
||||
// Genere ligne de titre
|
||||
$objmodel->write_title($this->array_export_fields[$indice],$array_selected,$outputlangs);
|
||||
$objmodel->write_title($this->array_export_fields[$indice],$array_selected,$outputlangs,$this->array_export_TypeFields[$indice]);
|
||||
|
||||
$var=true;
|
||||
|
||||
|
||||
@ -380,6 +380,8 @@ class PaiementFourn extends Paiement
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'facture_fourn as f';
|
||||
$sql.= ' WHERE pf.fk_facturefourn = f.rowid AND fk_paiementfourn = '.$this->id;
|
||||
if ($filter) $sql.= ' AND '.$filter;
|
||||
|
||||
dol_syslog(get_class($this).'::getBillsArray sql='.$sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -399,7 +401,7 @@ class PaiementFourn extends Paiement
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dol_syslog('PaiementFourn::getBillsArray Error '.$this->error.' - sql='.$sql);
|
||||
dol_syslog(get_class($this).'::getBillsArray Error '.$this->error);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,8 @@ SavingAccount=Savings account
|
||||
SavingAccounts=Savings accounts
|
||||
ErrorBankLabelAlreadyExists=Financial account label already exists
|
||||
BankBalance=Balance
|
||||
BankBalanceBefore=Balance before
|
||||
BankBalanceAfter=Balance after
|
||||
BalanceMinimalAllowed=Minimum allowed balance
|
||||
BalanceMinimalDesired=Minimum desired balance
|
||||
InitialBankBalance=Initial balance
|
||||
|
||||
@ -20,6 +20,8 @@ SavingAccount=Compte épargne
|
||||
SavingAccounts=Comptes épargne/placements
|
||||
ErrorBankLabelAlreadyExists=Libellé de compte financier déjà existant
|
||||
BankBalance=Solde
|
||||
BankBalanceBefore=Solde avant
|
||||
BankBalanceAfter=Solde après
|
||||
BalanceMinimalAllowed=Solde minimum autorisé
|
||||
BalanceMinimalDesired=Solde minimum désiré
|
||||
InitialBankBalance=Solde initial
|
||||
|
||||
@ -140,7 +140,7 @@ SellsJournal=Journal des ventes
|
||||
PurchasesJournal=Journal des achats
|
||||
Journaux=Journaux
|
||||
InvoiceRef=Réf facture
|
||||
Piece=Piece compta
|
||||
Piece=Pièce compta
|
||||
DescSellsJournal=Journal des ventes
|
||||
DescPurchasesJournal=Journal des achats
|
||||
JournalNum=Journal
|
||||
|
||||
@ -43,6 +43,10 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php';
|
||||
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
@ -50,7 +54,10 @@ $error=0;
|
||||
|
||||
|
||||
|
||||
// -------------------- START OF YOUR CODE HERE --------------------
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
@ -64,12 +71,15 @@ $model=$argv[3];
|
||||
$newlangid='en_EN'; // To force a new lang id
|
||||
|
||||
|
||||
$invoicestatic=new Facture($db);
|
||||
$invoicesupplierstatic=new FactureFournisseur($db);
|
||||
$societestatic=new Societe($db);
|
||||
$chargestatic=new ChargeSociales($db);
|
||||
$chargestatic=new ChargeSociales($db);
|
||||
$memberstatic=new Adherent($db);
|
||||
$paymentstatic=new Paiement($db);
|
||||
$paymentsupplierstatic=new PaiementFourn($db);
|
||||
$paymentvatstatic=new TVA($db);
|
||||
$paymentsupplierstatic=new PaiementFourn($db);
|
||||
$paymentsocialcontributionstatic=new PaymentSocialContribution($db);
|
||||
$paymentvatstatic=new Tva($db);
|
||||
$bankstatic=new Account($db);
|
||||
$banklinestatic=new AccountLine($db);
|
||||
|
||||
@ -100,16 +110,23 @@ if (! empty($newlangid))
|
||||
$outputlangs->load("main");
|
||||
$outputlangs->load("bills");
|
||||
$outputlangs->load("companies");
|
||||
$outputlangs->load("banks");
|
||||
$outputlangs->load("banks");
|
||||
$outputlangs->load("members");
|
||||
$outputlangs->load("compta");
|
||||
|
||||
|
||||
$acct=new Account($db);
|
||||
$result=$acct->fetch('',$bankref);
|
||||
if ($result <= 0)
|
||||
{
|
||||
print "Failed to find bank account with ref ".$bankref."\n";
|
||||
print "Failed to find bank account with ref ".$bankref.".\n";
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Export for bank account ".$acct->ref." (".$acct->label.").\n";
|
||||
}
|
||||
|
||||
|
||||
// Creation de la classe d'export du model ExportXXX
|
||||
$dir = DOL_DOCUMENT_ROOT . "/core/modules/export/";
|
||||
@ -129,220 +146,297 @@ $dirname = $conf->banque->dir_temp;
|
||||
$filename = 'export-bank-receipts-'.$bankref.'-'.$num.'.'.$objmodel->extension;
|
||||
|
||||
|
||||
// Open file
|
||||
print 'Create file '.$filename.' into directory '.$dirname."\n";
|
||||
dol_mkdir($dirname);
|
||||
$result=$objmodel->open_file($dirname."/".$filename, $outputlangs);
|
||||
|
||||
if ($result >= 0)
|
||||
$array_fields=array(
|
||||
'bankreceipt'=>$outputlangs->transnoentitiesnoconv("AccountStatementShort"), 'bankaccount'=>$outputlangs->transnoentitiesnoconv("BankAccount"),
|
||||
'dateop'=>$outputlangs->transnoentitiesnoconv("DateOperationShort"),'dateval'=>$outputlangs->transnoentitiesnoconv("DateValueShort"),'type'=>$outputlangs->transnoentitiesnoconv("Type"),
|
||||
'description'=>$outputlangs->transnoentitiesnoconv("Description"), 'thirdparty'=>$outputlangs->transnoentitiesnoconv("Tiers"), 'accountelem'=>$outputlangs->transnoentitiesnoconv("Piece"),
|
||||
'debit'=>$outputlangs->transnoentitiesnoconv("Debit"), 'credit'=>$outputlangs->transnoentitiesnoconv("Credit"),
|
||||
'soldbefore'=>$outputlangs->transnoentitiesnoconv("BankBalanceBefore"), 'soldafter'=>$outputlangs->transnoentitiesnoconv("BankBalanceAfter"),
|
||||
'comment'=>$outputlangs->transnoentitiesnoconv("Comment")
|
||||
);
|
||||
$array_selected=array(
|
||||
'bankreceipt'=>'bankreceipt', 'bankaccount'=>'bankaccount',
|
||||
'dateop'=>'dateop','dateval'=>'dateval','type'=>'type',
|
||||
'description'=>'description', 'thirdparty'=>'thirdparty', 'accountelem'=>'accountelem',
|
||||
'debit'=>'debit', 'credit'=>'credit',
|
||||
'soldbefore'=>'soldbefore','soldafter'=>'soldafter',
|
||||
'comment'=>'comment'
|
||||
);
|
||||
$array_export_TypeFields=array(
|
||||
'bankreceipt'=>'Text', 'bankaccount'=>'Text',
|
||||
'dateop'=>'Date','dateval'=>'Date','type'=>'Text',
|
||||
'description'=>'Text', 'thirdparty'=>'Text', 'accountelem'=>'Text',
|
||||
'debit'=>'Number', 'credit'=>'Number',
|
||||
'soldbefore'=>'Number','soldafter'=>'Number',
|
||||
'comment'=>'Text'
|
||||
);
|
||||
|
||||
|
||||
// Recherche les ecritures pour le releve
|
||||
$listofnum="'";
|
||||
$arraynum=explode(',',$num);
|
||||
foreach($arraynum as $val)
|
||||
{
|
||||
$numrows=0;
|
||||
if ($listofnum != "'") $listofnum.="','";
|
||||
$listofnum.=$val;
|
||||
}
|
||||
$listofnum.="'";
|
||||
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,";
|
||||
$sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,";
|
||||
$sql.= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."bank as b";
|
||||
$sql.= " WHERE b.num_releve IN (".$listofnum.")";
|
||||
if (!isset($num)) $sql.= " OR b.num_releve is null";
|
||||
$sql.= " AND b.fk_account = ".$acct->id;
|
||||
$sql.= " AND b.fk_account = ba.rowid";
|
||||
$sql.= $db->order("b.num_releve, b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day
|
||||
//print $sql;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$balancebefore=array();
|
||||
|
||||
$array_fields=array(
|
||||
'bankreceipt'=>$outputlangs->transnoentitiesnoconv("AccountStatementShort"), 'bankaccount'=>$outputlangs->transnoentitiesnoconv("BankAccount"),
|
||||
'dateop'=>$outputlangs->transnoentitiesnoconv("DateOperationShort"),'dateval'=>$outputlangs->transnoentitiesnoconv("DateValueShort"),'type'=>$outputlangs->transnoentitiesnoconv("Type"),
|
||||
'description'=>$outputlangs->transnoentitiesnoconv("Description"), 'thirdparty'=>$outputlangs->transnoentitiesnoconv("Tiers"), 'invoices'=>$outputlangs->transnoentitiesnoconv("Invoices"),
|
||||
'debit'=>$outputlangs->transnoentitiesnoconv("Debit"), 'credit'=>$outputlangs->transnoentitiesnoconv("Credit"), 'sold'=>$outputlangs->transnoentitiesnoconv("Solde"), 'comment'=>$outputlangs->transnoentitiesnoconv("Comment")
|
||||
);
|
||||
$array_selected=array(
|
||||
'bankreceipt'=>'bankreceipt', 'bankaccount'=>'bankaccount',
|
||||
'dateop'=>'dateop','dateval'=>'dateval','type'=>'type',
|
||||
'description'=>'description', 'thirdparty'=>'thirdparty', 'invoices'=>'invoices',
|
||||
'debit'=>'debit', 'credit'=>'credit', 'sold'=>'sold', 'comment'=>'comment'
|
||||
);
|
||||
$array_export_TypeFields=array(
|
||||
'bankreceipt'=>'Text', 'bankaccount'=>'Text',
|
||||
'dateop'=>'Date','dateval'=>'Date','type'=>'Text',
|
||||
'description'=>'Text', 'thirdparty'=>'Text', 'invoices'=>'Text',
|
||||
'debit'=>'Number', 'credit'=>'Number', 'sold'=>'Number', 'comment'=>'Text'
|
||||
);
|
||||
$numrows = $db->num_rows($resql);
|
||||
|
||||
// Genere en-tete
|
||||
$objmodel->write_header($outputlangs);
|
||||
|
||||
// Genere ligne de titre
|
||||
$objmodel->write_title($array_fields,$array_selected,$outputlangs);
|
||||
|
||||
|
||||
// Recherche les ecritures pour le releve
|
||||
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,";
|
||||
$sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,";
|
||||
$sql.= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."bank as b";
|
||||
$sql.= " WHERE b.num_releve='".$db->escape($num)."'";
|
||||
if (!isset($num)) $sql.= " OR b.num_releve is null";
|
||||
//$sql.= " AND b.fk_account = ".$acct->id;
|
||||
$sql.= " AND b.fk_account = ba.rowid";
|
||||
$sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
if ($numrows > 0)
|
||||
{
|
||||
$numrows = $db->num_rows($resql);
|
||||
// Open file
|
||||
print 'Open file '.$filename.' into directory '.$dirname."\n";
|
||||
dol_mkdir($dirname);
|
||||
$result=$objmodel->open_file($dirname."/".$filename, $outputlangs);
|
||||
|
||||
if ($result < 0)
|
||||
{
|
||||
print 'Failed to create file '.$filename.' into dir '.$dirname.'.'."\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Genere en-tete
|
||||
$objmodel->write_header($outputlangs);
|
||||
|
||||
// Genere ligne de titre
|
||||
$objmodel->write_title($array_fields,$array_selected,$outputlangs,$array_export_TypeFields);
|
||||
}
|
||||
|
||||
$i=0;
|
||||
while ($i < $numrows)
|
||||
$i=0;
|
||||
while ($i < $numrows)
|
||||
{
|
||||
$thirdparty='';
|
||||
$accountelem='';
|
||||
$comment='';
|
||||
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
// Calculate start balance
|
||||
if (! isset($balancebefore[$objp->num_releve]))
|
||||
{
|
||||
print "Lines ".$i."\n";
|
||||
print 'Calculate start balance for receipt '.$objp->num_releve."\n";
|
||||
|
||||
$objp = $db->fetch_object($result);
|
||||
$total = $total + $objp->amount;
|
||||
|
||||
$var=!$var;
|
||||
|
||||
// Date operation
|
||||
$dateop=$db->jdate($objp->do);
|
||||
|
||||
// Date de valeur
|
||||
$datevalue=$db->jdate($objp->dv);
|
||||
|
||||
// Num cheque
|
||||
$numchq=($objp->num_chq?$objp->num_chq:'');
|
||||
|
||||
// Libelle
|
||||
$reg=array();
|
||||
preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthese on tente recherche de traduction
|
||||
if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) $desc=$langs->trans($reg[1]);
|
||||
else $desc=$objp->label;
|
||||
|
||||
/*
|
||||
* Ajout les liens (societe, company...)
|
||||
*/
|
||||
$newline=1;
|
||||
$links = $acct->get_url($objp->rowid);
|
||||
foreach($links as $key=>$val)
|
||||
$sql2 = "SELECT sum(b.amount) as amount";
|
||||
$sql2.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||
$sql2.= " WHERE b.num_releve < '".$db->escape($objp->num_releve)."'";
|
||||
$sql2.= " AND b.fk_account = ".$objp->bankid;
|
||||
$resql2=$db->query($sql2);
|
||||
if ($resql2)
|
||||
{
|
||||
if (! $newline) print ' - ';
|
||||
else print '<br>';
|
||||
if ($links[$key]['type']=='payment')
|
||||
{
|
||||
$paymentstatic->id=$links[$key]['url_id'];
|
||||
$paymentstatic->ref=$langs->trans("Payment");
|
||||
print ' '.$paymentstatic->getNomUrl(1);
|
||||
$newline=0;
|
||||
}
|
||||
elseif ($links[$key]['type']=='payment_supplier')
|
||||
{
|
||||
$paymentsupplierstatic->id=$links[$key]['url_id'];
|
||||
$paymentsupplierstatic->ref=$langs->trans("Payment");;
|
||||
print ' '.$paymentsupplierstatic->getNomUrl(1);
|
||||
$newline=0;
|
||||
}
|
||||
elseif ($links[$key]['type']=='payment_sc')
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/fiche.php?id='.$links[$key]['url_id'].'">';
|
||||
print ' '.img_object($langs->trans('ShowPayment'),'payment').' ';
|
||||
print $langs->trans("SocialContributionPayment");
|
||||
print '</a>';
|
||||
$newline=0;
|
||||
}
|
||||
elseif ($links[$key]['type']=='payment_vat')
|
||||
{
|
||||
$paymentvatstatic->id=$links[$key]['url_id'];
|
||||
$paymentvatstatic->ref=$langs->trans("Payment");
|
||||
print ' '.$paymentvatstatic->getNomUrl(2);
|
||||
}
|
||||
elseif ($links[$key]['type']=='banktransfert') {
|
||||
// Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
|
||||
if ($objp->amount > 0)
|
||||
{
|
||||
$banklinestatic->fetch($links[$key]['url_id']);
|
||||
$bankstatic->id=$banklinestatic->fk_account;
|
||||
$bankstatic->label=$banklinestatic->bank_account_label;
|
||||
print ' ('.$langs->trans("from").' ';
|
||||
print $bankstatic->getNomUrl(1,'transactions');
|
||||
print ' '.$langs->trans("toward").' ';
|
||||
$bankstatic->id=$objp->bankid;
|
||||
$bankstatic->label=$objp->bankref;
|
||||
print $bankstatic->getNomUrl(1,'');
|
||||
print ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
$bankstatic->id=$objp->bankid;
|
||||
$bankstatic->label=$objp->bankref;
|
||||
print ' ('.$langs->trans("from").' ';
|
||||
print $bankstatic->getNomUrl(1,'');
|
||||
print ' '.$langs->trans("toward").' ';
|
||||
$banklinestatic->fetch($links[$key]['url_id']);
|
||||
$bankstatic->id=$banklinestatic->fk_account;
|
||||
$bankstatic->label=$banklinestatic->bank_account_label;
|
||||
print $bankstatic->getNomUrl(1,'transactions');
|
||||
print ')';
|
||||
}
|
||||
}
|
||||
elseif ($links[$key]['type']=='company') {
|
||||
print '<a href="'.DOL_URL_ROOT.'/societe/soc.php?socid='.$links[$key]['url_id'].'">';
|
||||
print img_object($langs->trans('ShowCustomer'),'company').' ';
|
||||
print dol_trunc($links[$key]['label'],24);
|
||||
print '</a>';
|
||||
$newline=0;
|
||||
}
|
||||
elseif ($links[$key]['type']=='member') {
|
||||
print '<a href="'.DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$links[$key]['url_id'].'">';
|
||||
print img_object($langs->trans('ShowMember'),'user').' ';
|
||||
print $links[$key]['label'];
|
||||
print '</a>';
|
||||
$newline=0;
|
||||
}
|
||||
elseif ($links[$key]['type']=='sc') {
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$links[$key]['url_id'].'">';
|
||||
print img_object($langs->trans('ShowBill'),'bill').' ';
|
||||
print $langs->trans("SocialContribution");
|
||||
print '</a>';
|
||||
$newline=0;
|
||||
}
|
||||
else {
|
||||
print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
|
||||
print $links[$key]['label'];
|
||||
print '</a>';
|
||||
$newline=0;
|
||||
}
|
||||
$obj2=$db->fetch_object($resql2);
|
||||
$balancebefore[$objp->num_releve] = ($obj2->amount?$obj2->amount:0);
|
||||
$db->free($resql2);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
if ($objp->amount < 0)
|
||||
{
|
||||
$totald = $totald + abs($objp->amount);
|
||||
$debit=price($objp->amount * -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$totalc = $totalc + abs($objp->amount);
|
||||
$credit=price($objp->amount);
|
||||
}
|
||||
|
||||
$i++;
|
||||
|
||||
// end of special operation processing
|
||||
$objmodel->write_record($array_selected,$objp,$outputlangs,$array_export_TypeFields);
|
||||
$total = $balancebefore[$objp->num_releve];
|
||||
}
|
||||
|
||||
$totalbefore = $total;
|
||||
$total = $total + $objp->amount;
|
||||
|
||||
$var=!$var;
|
||||
|
||||
// Date operation
|
||||
$dateop=$db->jdate($objp->do);
|
||||
|
||||
// Date de valeur
|
||||
$datevalue=$db->jdate($objp->dv);
|
||||
|
||||
// Num cheque
|
||||
$numchq=($objp->num_chq?$objp->num_chq:'');
|
||||
|
||||
// Libelle
|
||||
$reg=array();
|
||||
preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthese on tente recherche de traduction
|
||||
if ($reg[1] && $langs->transnoentitiesnoconv($reg[1])!=$reg[1]) $description=$langs->transnoentitiesnoconv($reg[1]);
|
||||
else $description=$objp->label;
|
||||
|
||||
/*
|
||||
* Ajout les liens (societe, company...)
|
||||
*/
|
||||
$links = $acct->get_url($objp->rowid);
|
||||
foreach($links as $key=>$val)
|
||||
{
|
||||
if ($links[$key]['type']=='payment')
|
||||
{
|
||||
$paymentstatic->fetch($links[$key]['url_id']);
|
||||
$tmparray=$paymentstatic->getBillsArray('');
|
||||
foreach($tmparray as $key => $val)
|
||||
{
|
||||
$invoicestatic->fetch($val);
|
||||
if ($accountelem) $accountelem.= ', ';
|
||||
$accountelem.=$invoicestatic->ref;
|
||||
}
|
||||
}
|
||||
elseif ($links[$key]['type']=='payment_supplier')
|
||||
{
|
||||
$paymentsupplierstatic->fetch($links[$key]['url_id']);
|
||||
$tmparray=$paymentsupplierstatic->getBillsArray('');
|
||||
foreach($tmparray as $key => $val)
|
||||
{
|
||||
$invoicesupplierstatic->fetch($val);
|
||||
if ($accountelem) $accountelem.= ', ';
|
||||
$accountelem.=$invoicesupplierstatic->ref;
|
||||
}
|
||||
}
|
||||
elseif ($links[$key]['type']=='payment_sc')
|
||||
{
|
||||
$paymentsocialcontributionstatic->fetch($links[$key]['url_id']);
|
||||
if ($accountelem) $accountelem.= ', ';
|
||||
$accountelem.=$langs->transnoentitiesnoconv("SocialContribution").' '.$paymentsocialcontributionstatic->ref;
|
||||
}
|
||||
elseif ($links[$key]['type']=='payment_vat')
|
||||
{
|
||||
$paymentvatstatic->fetch($links[$key]['url_id']);
|
||||
if ($accountelem) $accountelem.= ', ';
|
||||
$accountelem.=$langs->transnoentitiesnoconv("VATPayments").' '.$paymentvatstatic->ref;
|
||||
}
|
||||
elseif ($links[$key]['type']=='banktransfert')
|
||||
{
|
||||
$comment=$outputlangs->transnoentitiesnoconv("Transfer");
|
||||
if ($objp->amount > 0)
|
||||
{
|
||||
if ($comment) $comment.= ' ';
|
||||
$banklinestatic->fetch($links[$key]['url_id']);
|
||||
$bankstatic->id=$banklinestatic->fk_account;
|
||||
$bankstatic->label=$banklinestatic->bank_account_label;
|
||||
$comment.= ' ('.$langs->transnoentitiesnoconv("from").' ';
|
||||
$comment.= $bankstatic->getNomUrl(1,'transactions');
|
||||
$comment.= ' '.$langs->transnoentitiesnoconv("toward").' ';
|
||||
$bankstatic->id=$objp->bankid;
|
||||
$bankstatic->label=$objp->bankref;
|
||||
$comment.= $bankstatic->getNomUrl(1,'');
|
||||
$comment.= ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($comment) $comment.= ' ';
|
||||
$bankstatic->id=$objp->bankid;
|
||||
$bankstatic->label=$objp->bankref;
|
||||
$comment.= ' ('.$langs->transnoentitiesnoconv("from").' ';
|
||||
$comment.= $bankstatic->getNomUrl(1,'');
|
||||
$comment.= ' '.$langs->transnoentitiesnoconv("toward").' ';
|
||||
$banklinestatic->fetch($links[$key]['url_id']);
|
||||
$bankstatic->id=$banklinestatic->fk_account;
|
||||
$bankstatic->label=$banklinestatic->bank_account_label;
|
||||
$comment.= $bankstatic->getNomUrl(1,'transactions');
|
||||
$comment.= ')';
|
||||
}
|
||||
}
|
||||
elseif ($links[$key]['type']=='company')
|
||||
{
|
||||
if ($thirdparty) $thirdparty.= ', ';
|
||||
$thirdparty.= dol_trunc($links[$key]['label'],24);
|
||||
$newline=0;
|
||||
}
|
||||
elseif ($links[$key]['type']=='member')
|
||||
{
|
||||
if ($thirdparty) $accountelem.= ', ';
|
||||
$thirdparty.= $links[$key]['label'];
|
||||
$newline=0;
|
||||
}
|
||||
/*elseif ($links[$key]['type']=='sc')
|
||||
{
|
||||
if ($accountelem) $accountelem.= ', ';
|
||||
//$accountelem.= '<a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$links[$key]['url_id'].'">';
|
||||
//$accountelem.= img_object($langs->transnoentitiesnoconv('ShowBill'),'bill').' ';
|
||||
$accountelem.= $langs->transnoentitiesnoconv("SocialContribution");
|
||||
//$accountelem.= '</a>';
|
||||
$newline=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($accountelem) $accountelem.= ', ';
|
||||
//$accountelem.= '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
|
||||
$accountelem.= $links[$key]['label'];
|
||||
//$accountelem.= '</a>';
|
||||
$newline=0;
|
||||
}*/
|
||||
}
|
||||
|
||||
$debit=$credit='';
|
||||
if ($objp->amount < 0)
|
||||
{
|
||||
$totald = $totald + abs($objp->amount);
|
||||
$debit=price2num($objp->amount * -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$totalc = $totalc + abs($objp->amount);
|
||||
$credit=price2num($objp->amount);
|
||||
}
|
||||
|
||||
$i++;
|
||||
|
||||
$rec=new stdClass();
|
||||
$rec->bankreceipt=$objp->num_releve;
|
||||
$rec->bankaccount=$objp->banklabel;
|
||||
$rec->dateop=dol_print_date($dateop,'dayrfc');
|
||||
$rec->dateval=dol_print_date($datevalue,'dayrfc');
|
||||
$rec->type=$objp->fk_type.' '.($objp->num_chq?$objp->num_chq:'');
|
||||
$rec->description=$description;
|
||||
$rec->thirdparty=$thirdparty;
|
||||
$rec->accountelem=$accountelem;
|
||||
$rec->debit=$debit;
|
||||
$rec->credit=$credit;
|
||||
$rec->sold=$sold;
|
||||
$rec->comment=$comment;
|
||||
$rec->soldbefore=price2num($totalbefore);
|
||||
$rec->soldafter=price2num($total);
|
||||
|
||||
// end of special operation processing
|
||||
$objmodel->write_record($array_selected,$rec,$outputlangs,$array_export_TypeFields);
|
||||
}
|
||||
else dol_print_error($db);
|
||||
|
||||
print "Found ".$numrows." records\n";
|
||||
if ($numrows > 0)
|
||||
{
|
||||
print "Found ".$numrows." records for receipt ".$num."\n";
|
||||
|
||||
// Genere en-tete
|
||||
$objmodel->write_footer($outputlangs);
|
||||
// Genere en-tete
|
||||
$objmodel->write_footer($outputlangs);
|
||||
|
||||
// Close file
|
||||
$objmodel->close_file();
|
||||
// Close file
|
||||
$objmodel->close_file();
|
||||
|
||||
print 'File '.$filename.' was generated into dir '.$dirname.'.'."\n";
|
||||
print 'File '.$filename.' was generated into dir '.$dirname.'.'."\n";
|
||||
|
||||
$ret=0;
|
||||
$ret=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "No records found for receipt ".$num."\n";
|
||||
|
||||
$ret=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print 'Failed to create file '.$filename.' into dir '.$dirname.'.'."\n";
|
||||
|
||||
dol_print_error($db);
|
||||
$ret=-1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
return $ret;
|
||||
|
||||
@ -40,8 +40,6 @@ if (! isset($argv[1]) || ! $argv[1]) {
|
||||
}
|
||||
$now=$argv[1];
|
||||
|
||||
// Recupere env dolibarr
|
||||
$version='1.10';
|
||||
|
||||
require_once($path."../../htdocs/master.inc.php");
|
||||
//require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_workbook.inc.php");
|
||||
@ -51,8 +49,18 @@ require_once(PHPEXCEL_PATH."/PHPExcel.php");
|
||||
//require_once(PHPEXCEL_PATH."/PHPExcel/Writer/Excel2007.php");
|
||||
require_once(PHPEXCEL_PATH."/PHPExcel/Writer/Excel5.php");
|
||||
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
$fname = DOL_DATA_ROOT.'/export-contacts.xls';
|
||||
|
||||
//$objPHPExcel = new writeexcel_workbook($fname);
|
||||
|
||||
@ -40,18 +40,23 @@ if (! isset($argv[1]) || ! $argv[1]) {
|
||||
}
|
||||
$now=$argv[1];
|
||||
|
||||
// Recupere env dolibarr
|
||||
$version='1.25';
|
||||
|
||||
require_once($path."../../htdocs/master.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
|
||||
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
|
||||
|
||||
print "***** $script_file ($version) *****\n";
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
print "Mails sending disabled (useless in batch mode)\n";
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1; // On bloque les mails
|
||||
|
||||
@ -55,20 +55,27 @@ $langs->load('main');
|
||||
$langs->load('contracts');
|
||||
|
||||
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
$now=dol_now('tzserver');
|
||||
$duration_value=$argv[2];
|
||||
|
||||
$error = 0;
|
||||
print $script_file." launched with mode ".$mode.($duration_value?" delay=".$duration_value:"")."\n";
|
||||
|
||||
$sql = "SELECT DISTINCT s.nom as name, c.ref, cd.date_fin_validite, cd.total_ttc, p.label label, s.email, s.default_lang";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe AS s";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."contrat AS c";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."contratdet AS cd";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."contrat AS c";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."contratdet AS cd";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product AS p ON p.rowid = cd.fk_product";
|
||||
$sql .= " WHERE s.rowid = c.fk_soc AND c.rowid = cd.fk_contrat AND c.statut > 0 AND cd.statut<5";
|
||||
|
||||
@ -173,10 +180,10 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldcustomer,$dura
|
||||
global $conf,$langs;
|
||||
|
||||
$newlangs=new Translate('',$conf);
|
||||
$newlangs->setDefaultLang($userlang);
|
||||
$newlangs->setDefaultLang(empty($userlang)?(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT):$userlang);
|
||||
$newlangs->load("main");
|
||||
$newlangs->load("contracts");
|
||||
|
||||
|
||||
if ($duration_value)
|
||||
$title=$newlangs->transnoentities("ListOfServicesToExpireWithDuration",$duration_value);
|
||||
else
|
||||
|
||||
@ -55,14 +55,21 @@ $langs->load('main');
|
||||
$langs->load('contracts');
|
||||
|
||||
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
$now=dol_now('tzserver');
|
||||
$duration_value=$argv[2];
|
||||
|
||||
$error = 0;
|
||||
print $script_file." launched with mode ".$mode.($duration_value?" delay=".$duration_value:"")."\n";
|
||||
|
||||
$sql = "SELECT DISTINCT s.nom, c.ref, cd.date_fin_validite, cd.total_ttc, p.label label, c.fk_soc,u.rowid AS uid, u.lastname, u.firstname, u.email, u.lang";
|
||||
@ -173,7 +180,7 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldsalerepresenta
|
||||
global $conf,$langs;
|
||||
|
||||
$newlangs=new Translate('',$conf);
|
||||
$newlangs->setDefaultLang($userlang);
|
||||
$newlangs->setDefaultLang(empty($userlang)?(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT):$userlang);
|
||||
$newlangs->load("main");
|
||||
$newlangs->load("contracts");
|
||||
|
||||
@ -181,7 +188,7 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldsalerepresenta
|
||||
$title=$newlangs->transnoentities("ListOfServicesToExpireWithDuration",$duration_value);
|
||||
else
|
||||
$title= $newlangs->transnoentities("ListOfServicesToExpire");
|
||||
|
||||
|
||||
$subject = "[".(empty($conf->global->MAIN_APPLICATION_TITLE)?'Dolibarr':$conf->global->MAIN_APPLICATION_TITLE)."] ".$title;
|
||||
$sendto = $oldemail;
|
||||
$from = $conf->global->MAIN_MAIL_EMAIL_FROM;
|
||||
|
||||
@ -59,10 +59,17 @@ require_once (DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php");
|
||||
require_once (DOL_DOCUMENT_ROOT.'/user/class/user.class.php');
|
||||
require_once (DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php");
|
||||
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
// Check security key
|
||||
if ($key != $conf->global->CRON_KEY)
|
||||
|
||||
@ -45,7 +45,19 @@ require_once ($path."../../htdocs/master.inc.php");
|
||||
require_once (DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php");
|
||||
|
||||
|
||||
$error = 0;
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
|
||||
|
||||
// We get list of emailing to process
|
||||
|
||||
@ -36,9 +36,9 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm')))
|
||||
if (! isset($argv[2]) || ! $argv[2] || ! in_array($argv[1],array('test','confirm')) || ! in_array($argv[2],array('thirdparties','contacts')))
|
||||
{
|
||||
print "Usage: $script_file [test|confirm] [delay]\n";
|
||||
print "Usage: $script_file (test|confirm) (thirdparties|contacts) [delay]\n";
|
||||
print "\n";
|
||||
print "Send an email to customers to remind all unpaid customer invoices.\n";
|
||||
print "If you choose 'test' mode, no emails are sent.\n";
|
||||
@ -46,6 +46,7 @@ if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm
|
||||
exit;
|
||||
}
|
||||
$mode=$argv[1];
|
||||
$targettype=$argv[2];
|
||||
|
||||
|
||||
require($path."../../htdocs/master.inc.php");
|
||||
@ -53,24 +54,37 @@ require_once (DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php");
|
||||
|
||||
$langs->load('main');
|
||||
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
$now=dol_now('tzserver');
|
||||
$duration_value=$argv[2];
|
||||
$duration_value=isset($argv[3])?$argv[3]:-1;
|
||||
|
||||
$error = 0;
|
||||
print $script_file." launched with mode ".$mode.($duration_value?" delay=".$duration_value:"")."\n";
|
||||
print $script_file." launched with mode ".$mode.($duration_value>=0?" delay=".$duration_value:"")."\n";
|
||||
|
||||
$sql = "SELECT f.facnumber, f.total_ttc, f.date_lim_reglement as due_date, s.nom as name, s.email, s.default_lang";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE f.fk_statut != 0 AND f.paye = 0";
|
||||
$sql .= " AND f.fk_soc = s.rowid";
|
||||
if ($duration_value) $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'";
|
||||
$sql .= " ORDER BY s.email ASC, s.rowid ASC"; // Order by email to allow one message per email
|
||||
$sql = "SELECT f.facnumber, f.total_ttc, f.date_lim_reglement as due_date,";
|
||||
$sql.= " s.rowid as sid, s.nom as name, s.email, s.default_lang";
|
||||
if ($targettype == 'contacts') $sql.= ", sp.rowid as cid, sp.firstname as cfirstname, sp.lastname as clastname, sp.email as cemail";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
|
||||
if ($targettype == 'contacts') $sql.= ", ".MAIN_DB_PREFIX."socpeople as sp";
|
||||
$sql.= " WHERE f.fk_statut != 0 AND f.paye = 0";
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
if ($duration_value>=0) $sql.= " AND f.date_lim_reglement < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'";
|
||||
if ($targettype == 'contacts') $sql.= " AND s.rowid = sp.fk_soc";
|
||||
$sql.= " ORDER BY";
|
||||
if ($targettype == 'contacts') $sql.= " sp.email, sp.rowid,";
|
||||
$sql.= " s.email ASC, s.rowid ASC, f.facnumber ASC"; // Order by email to allow one message per email
|
||||
|
||||
//print $sql;
|
||||
$resql=$db->query($sql);
|
||||
@ -78,10 +92,12 @@ if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$oldemail = 'none'; $olduid = 0; $oldlang='';
|
||||
$oldemail = 'none'; $oldsid = 0; $oldcid = 0; $oldlang='';
|
||||
$total = 0; $foundtoprocess = 0;
|
||||
print "We found ".$num." couples (unpayed validated invoice - customer) qualified\n";
|
||||
dol_syslog("We found ".$num." couples (unpayed validated invoice - customer) qualified");
|
||||
$trackthirdpartiessent = array();
|
||||
|
||||
print "We found ".$num." couples (unpayed validated invoices-".$targettype.") qualified\n";
|
||||
dol_syslog("We found ".$num." couples (unpayed validated invoices-".$targettype.") qualified");
|
||||
$message='';
|
||||
|
||||
if ($num)
|
||||
@ -90,36 +106,50 @@ if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
if (($obj->email <> $oldemail || $obj->uid <> $olduid) || $oldemail == 'none')
|
||||
$newemail=empty($obj->cemail)?$obj->email:$obj->cemail;
|
||||
|
||||
// Check if this record is a break after previous one
|
||||
$startbreak=false;
|
||||
if ($newemail <> $oldemail || $oldemail == 'none') $startbreak=true;
|
||||
if ($obj->sid && $obj->sid <> $oldsid) $startbreak=true;
|
||||
if ($obj->cid && $obj->cid <> $oldcid) $startbreak=true;
|
||||
|
||||
if ($startbreak)
|
||||
{
|
||||
// Break onto sales representative (new email or uid)
|
||||
if (dol_strlen($oldemail) && $oldemail != 'none')
|
||||
// Break onto sales representative (new email or cid)
|
||||
if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail]))
|
||||
{
|
||||
envoi_mail($mode,$oldemail,$message,$total,$oldlang,$oldcustomer);
|
||||
envoi_mail($mode,$oldemail,$message,$total,$oldlang,$oldtarget);
|
||||
$trackthirdpartiessent[$oldsid.'|'.$oldemail]='contact id '.$oldcid;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($oldemail != 'none') print "- No email sent for ".$oldcustomer.", total: ".$total."\n";
|
||||
{
|
||||
if ($oldemail != 'none')
|
||||
{
|
||||
if (empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) print "- No email sent for '".$oldtarget."', total: ".$total."\n";
|
||||
else print "- No email sent for '".$oldtarget."', total: ".$total." (already sent to ".$trackthirdpartiessent[$oldsid.'|'.$oldemail].")\n";
|
||||
}
|
||||
}
|
||||
$oldemail = $obj->email;
|
||||
$olduid = $obj->uid;
|
||||
$oldemail = $newemail;
|
||||
$oldsid = $obj->sid;
|
||||
$oldcid = $obj->cid;
|
||||
$oldlang = $obj->lang;
|
||||
$oldcustomer=$obj->name;
|
||||
$oldtarget=(empty($obj->cfirstname) && empty($obj->clastname))?$obj->name:($obj->clastname." ".$obj->cfirstname);
|
||||
$message = '';
|
||||
$total = 0;
|
||||
$total = 0;
|
||||
$foundtoprocess = 0;
|
||||
$customer=$obj->name;
|
||||
if (empty($obj->email)) print "Warning: Customer ".$customer." has no email. Notice disabled.\n";
|
||||
$target=(empty($obj->cfirstname) && empty($obj->clastname))?$obj->name:($obj->clastname." ".$obj->cfirstname);
|
||||
//if (empty($newemail)) print "Warning: Customer ".$target." has no email. Notice disabled.\n";
|
||||
}
|
||||
|
||||
if (dol_strlen($oldemail))
|
||||
if (dol_strlen($newemail))
|
||||
{
|
||||
$message .= $langs->trans("Invoice")." ".$obj->facnumber." : ".price($obj->total_ttc)." : ".$obj->name."\n";
|
||||
dol_syslog("email_unpaid_invoices_to_customers.php: ".$obj->email);
|
||||
$message .= $langs->trans("Invoice")." ".$obj->facnumber." : ".price($obj->total_ttc)."\n";
|
||||
dol_syslog("email_unpaid_invoices_to_customers.php: ".$newemail." ".$message);
|
||||
$foundtoprocess++;
|
||||
}
|
||||
print "Unpaid invoice ".$obj->facnumber.", price ".price2num($obj->total_ttc).", due date ".dol_print_date($db->jdate($obj->due_date),'day')." customer ".$obj->name.", email ".$obj->email.": ";
|
||||
if (dol_strlen($obj->email)) print "qualified.";
|
||||
print "Unpaid invoice ".$obj->facnumber.", price ".price2num($obj->total_ttc).", due date ".dol_print_date($db->jdate($obj->due_date),'day')." customer id ".$obj->sid." ".$obj->name.", ".($obj->cid?"contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.",":"")." email ".$newemail.": ";
|
||||
if (dol_strlen($newemail)) print "qualified.";
|
||||
else print "disqualified (no email).";
|
||||
print "\n";
|
||||
|
||||
@ -131,13 +161,18 @@ if ($resql)
|
||||
// Si il reste des envois en buffer
|
||||
if ($foundtoprocess)
|
||||
{
|
||||
if (dol_strlen($oldemail) && $oldemail != 'none') // Break onto email (new email)
|
||||
if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) // Break onto email (new email)
|
||||
{
|
||||
envoi_mail($mode,$oldemail,$message,$total,$oldlang,$oldcustomer);
|
||||
envoi_mail($mode,$oldemail,$message,$total,$oldlang,$oldtarget);
|
||||
$trackthirdpartiessent[$oldsid.'|'.$oldemail]='contact id '.$oldcid;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($oldemail != 'none') print "- No email sent for ".$oldcustomer.", total: ".$total."\n";
|
||||
if ($oldemail != 'none')
|
||||
{
|
||||
if (empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) print "- No email sent for '".$oldtarget."', total: ".$total."\n";
|
||||
else print "- No email sent for '".$oldtarget."', total: ".$total." (already sent to ".$trackthirdpartiessent[$oldsid.'|'.$oldemail].")\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -157,19 +192,19 @@ else
|
||||
* Send email
|
||||
*
|
||||
* @param string $mode Mode (test | confirm)
|
||||
* @param string $oldemail Old email
|
||||
* @param string $oldemail Target email
|
||||
* @param string $message Message to send
|
||||
* @param string $total Total amount of unpayed invoices
|
||||
* @param string $userlang Code lang to use for email output.
|
||||
* @param string $oldcustomer Old customer
|
||||
* @param string $oldtarget Target name
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldcustomer)
|
||||
function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldtarget)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
$newlangs=new Translate('',$conf);
|
||||
$newlangs->setDefaultLang($userlang);
|
||||
$newlangs->setDefaultLang(empty($userlang)?(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT):$userlang);
|
||||
$newlangs->load("main");
|
||||
$newlangs->load("bills");
|
||||
|
||||
@ -179,7 +214,7 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldcustomer)
|
||||
$errorsto = $conf->global->MAIN_MAIL_ERRORS_TO;
|
||||
$msgishtml = 0;
|
||||
|
||||
print "- Send email for ".$oldcustomer."(".$oldemail."), total: ".$total."\n";
|
||||
print "- Send email for '".$oldtarget."' (".$oldemail."), total: ".$total."\n";
|
||||
dol_syslog("email_unpaid_invoices_to_customers.php: send mail to ".$oldemail);
|
||||
|
||||
$usehtml=0;
|
||||
|
||||
@ -54,15 +54,23 @@ require_once (DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php");
|
||||
$langs->load('main');
|
||||
|
||||
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
$now=dol_now('tzserver');
|
||||
$duration_value=$argv[2];
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
$error = 0;
|
||||
print $script_file." launched with mode ".$mode.($duration_value?" delay=".$duration_value:"")."\n";
|
||||
$now=dol_now('tzserver');
|
||||
$duration_value=isset($argv[2])?$argv[2]:-1;
|
||||
|
||||
print $script_file." launched with mode ".$mode.($duration_value>=0?" delay=".$duration_value:"")."\n";
|
||||
|
||||
$sql = "SELECT f.facnumber, f.total_ttc, f.date_lim_reglement as due_date, s.nom as name, u.rowid as uid, u.lastname, u.firstname, u.email, u.lang";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
@ -71,10 +79,10 @@ $sql .= " , ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."user as u";
|
||||
$sql .= " WHERE f.fk_statut != 0 AND f.paye = 0";
|
||||
$sql .= " AND f.fk_soc = s.rowid";
|
||||
if ($duration_value) $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'";
|
||||
if ($duration_value>=0) $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'";
|
||||
$sql .= " AND sc.fk_soc = s.rowid";
|
||||
$sql .= " AND sc.fk_user = u.rowid";
|
||||
$sql .= " ORDER BY u.email ASC, s.rowid ASC"; // Order by email to allow one message per email
|
||||
$sql .= " ORDER BY u.email ASC, s.rowid ASC, f.facnumber ASC"; // Order by email to allow one message per email
|
||||
|
||||
//print $sql;
|
||||
$resql=$db->query($sql);
|
||||
@ -138,10 +146,10 @@ if ($resql)
|
||||
{
|
||||
envoi_mail($mode,$oldemail,$message,$total,$oldlang,$oldsalerepresentative);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($oldemail != 'none') print "- No email sent for ".$oldsalerepresentative.", total: ".$total."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($oldemail != 'none') print "- No email sent for ".$oldsalerepresentative.", total: ".$total."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -172,11 +180,11 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldsalerepresenta
|
||||
global $conf,$langs;
|
||||
|
||||
$newlangs=new Translate('',$conf);
|
||||
$newlangs->setDefaultLang($userlang);
|
||||
$newlangs->setDefaultLang(empty($userlang)?(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT):$userlang);
|
||||
$newlangs->load("main");
|
||||
$newlangs->load("bills");
|
||||
|
||||
$subject = "[".(empty($conf->global->MAIN_APPLICATION_TITLE)?'Dolibarr':$conf->global->MAIN_APPLICATION_TITLE)."] ".$newlangs->trans("ListOfYourUnpaidInvoices");
|
||||
$subject = "[".(empty($conf->global->MAIN_APPLICATION_TITLE)?'Dolibarr':$conf->global->MAIN_APPLICATION_TITLE)."] ".$newlangs->transnoentities("ListOfYourUnpaidInvoices");
|
||||
$sendto = $oldemail;
|
||||
$from = $conf->global->MAIN_MAIL_EMAIL_FROM;
|
||||
$errorsto = $conf->global->MAIN_MAIL_ERRORS_TO;
|
||||
@ -196,7 +204,7 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldsalerepresenta
|
||||
}
|
||||
else
|
||||
{
|
||||
$allmessage.= "List of unpaid invoices".($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n");
|
||||
$allmessage.= $newlangs->transnoentities("ListOfYourUnpaidInvoices").($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n");
|
||||
$allmessage.= "Note: This list contains only invoices for third parties you are linked to as a sale representative.".($usehtml?"<br>\n":"\n");
|
||||
}
|
||||
$allmessage.= $message.($usehtml?"<br>\n":"\n");
|
||||
|
||||
@ -50,7 +50,11 @@ $version=DOL_VERSION;
|
||||
$error=0;
|
||||
|
||||
|
||||
// -------------------- START OF YOUR CODE HERE --------------------
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
@ -118,6 +122,11 @@ foreach ($argv as $key => $value)
|
||||
|
||||
$paymentdateafter=dol_stringtotime($argv[$key+1]);
|
||||
$paymentdatebefore=dol_stringtotime($argv[$key+2]);
|
||||
if (empty($paymentdateafter) || empty($paymentdatebefore))
|
||||
{
|
||||
print 'Error: Bad date format'."\n";
|
||||
exit;
|
||||
}
|
||||
print 'Rebuild PDF for invoices with at least one payment between '.dol_print_date($paymentdateafter,'day')." and ".dol_print_date($paymentdatebefore,'day').".\n";
|
||||
}
|
||||
|
||||
@ -130,7 +139,25 @@ foreach ($argv as $key => $value)
|
||||
print 'Rebuild PDF for invoices with no payment done yet.'."\n";
|
||||
}
|
||||
|
||||
if ($value == 'filter=nodeposit')
|
||||
if ($value == 'filter=bank')
|
||||
{
|
||||
$found=true;
|
||||
$option.=(empty($option)?'':'_').'bank_'.$argv[$key+1];
|
||||
$filter[]='bank';
|
||||
|
||||
$paymentonbankref=$argv[$key+1];
|
||||
$bankaccount=new Account($db);
|
||||
$result=$bankaccount->fetch(0,$paymentonbankref);
|
||||
if ($result <= 0)
|
||||
{
|
||||
print 'Error: Bank account with ref "'.$paymentonbankref.'" not found'."\n";
|
||||
exit;
|
||||
}
|
||||
$paymentonbankid=$bankaccount->id;
|
||||
print 'Rebuild PDF for invoices with at least one payment on financial account '.$bankaccount->ref."\n";
|
||||
}
|
||||
|
||||
if ($value == 'filter=nodeposit')
|
||||
{
|
||||
$found=true;
|
||||
$option.=(empty($option)?'':'_').'nodeposit';
|
||||
@ -169,16 +196,21 @@ if (empty($option) && count($filter) <= 0)
|
||||
exit;
|
||||
}
|
||||
// Check if there is no uncompatible choice
|
||||
if (in_array('payments',$filter) && in_array('nopayment',$filter))
|
||||
{
|
||||
usage();
|
||||
exit;
|
||||
}
|
||||
if (in_array('payments',$filter) && in_array('nopayment',$filter))
|
||||
{
|
||||
usage();
|
||||
exit;
|
||||
}
|
||||
if (in_array('bank',$filter) && in_array('nopayment',$filter))
|
||||
{
|
||||
usage();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// Define SQL and SQL request to select invoices
|
||||
// Use $filter, $dateafterdate, datebeforedate, $paymentdateafter, $paymentdatebefore
|
||||
$result=rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, 1, $regenerate, $option);
|
||||
$result=rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, 1, $regenerate, $option, $paymentonbankid);
|
||||
|
||||
|
||||
|
||||
@ -213,9 +245,11 @@ function usage()
|
||||
print "Rebuild PDF files for some invoices and merge PDF files into one.\n";
|
||||
print "\n";
|
||||
print "To build/merge PDF for invoices in a date range:\n";
|
||||
print "Usage: ".$script_file." filter=date dateafter datebefore [lang=langcode]\n";
|
||||
print "Usage: ".$script_file." filter=date dateafter datebefore\n";
|
||||
print "To build/merge PDF for invoices with at least one payment in a date range:\n";
|
||||
print "Usage: ".$script_file." filter=payments dateafter datebefore [lang=langcode]\n";
|
||||
print "Usage: ".$script_file." filter=payments dateafter datebefore\n";
|
||||
print "To build/merge PDF for invoices with at least one payment onto a bank account:\n";
|
||||
print "Usage: ".$script_file." filter=bank bankref\n";
|
||||
print "To build/merge PDF for all invoices, use filter=all\n";
|
||||
print "Usage: ".$script_file." filter=all\n";
|
||||
print "To build/merge PDF for invoices with no payments, use filter=nopayment\n";
|
||||
@ -224,9 +258,10 @@ function usage()
|
||||
print "To exclude replacement invoices, use filter=noreplacement\n";
|
||||
print "To exclude deposit invoices, use filter=nodeposit\n";
|
||||
print "To regenerate existing PDF, use regenerate=crabe\n";
|
||||
print "To generate invoices in a language, use lang=xx_XX\n";
|
||||
print "\n";
|
||||
print "Example: ".$script_file." filter=payments 20080101 20081231 lang=fr_FR regenerate=crabe\n";
|
||||
print "Example: ".$script_file." filter=all lang=it_IT\n";
|
||||
print "Example: ".$script_file." filter=all lang=en_US\n";
|
||||
print "\n";
|
||||
print "Note that some filters can be cumulated.\n";
|
||||
}
|
||||
|
||||
@ -34,21 +34,24 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Main
|
||||
$version='1.11';
|
||||
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
|
||||
@set_time_limit(0);
|
||||
$error=0;
|
||||
|
||||
require_once($path."../../htdocs/master.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
|
||||
|
||||
|
||||
$langs->load("main");
|
||||
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
|
||||
print "***** $script_file ($version) *****\n";
|
||||
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
if (! isset($argv[1]) || ! $argv[1]) {
|
||||
print "Usage: $script_file now\n";
|
||||
|
||||
@ -34,22 +34,29 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Main
|
||||
$version='1.14';
|
||||
@set_time_limit(0);
|
||||
$error=0;
|
||||
$forcecommit=0;
|
||||
|
||||
|
||||
require_once($path."../../htdocs/master.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/adherents/class/cotisation.class.php");
|
||||
|
||||
|
||||
$langs->load("main");
|
||||
$langs->load("errors");
|
||||
$langs->load("errors");
|
||||
|
||||
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
$forcecommit=0;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
// List of fields to get from LDAP
|
||||
$required_fields = array(
|
||||
|
||||
@ -40,17 +40,21 @@ if (! isset($argv[1]) || ! $argv[1]) {
|
||||
}
|
||||
$now=$argv[1];
|
||||
|
||||
// Recupere env dolibarr
|
||||
$version='1.10';
|
||||
|
||||
require_once($path."../../htdocs/master.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php");
|
||||
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
|
||||
|
||||
print "***** $script_file ($version) *****\n";
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
/*
|
||||
if (! $conf->global->LDAP_SYNCHRO_ACTIVE)
|
||||
|
||||
@ -35,24 +35,29 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once($path."../../htdocs/master.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php");
|
||||
|
||||
$langs->load("main");
|
||||
$langs->load("errors");
|
||||
|
||||
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
$forcecommit=0;
|
||||
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
// Main
|
||||
|
||||
$version='1.14';
|
||||
@set_time_limit(0);
|
||||
$error=0;
|
||||
$forcecommit=0;
|
||||
|
||||
require_once($path."../../htdocs/master.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php");
|
||||
|
||||
$langs->load("main");
|
||||
$langs->load("errors");
|
||||
|
||||
// List of fields to get from LDAP
|
||||
$required_fields = array(
|
||||
@ -136,11 +141,11 @@ if ($result >= 0)
|
||||
$group->entity = $conf->entity;
|
||||
|
||||
//print_r($ldapgroup);
|
||||
|
||||
|
||||
if($group->id > 0) { // Group update
|
||||
print $langs->transnoentities("GroupUpdate").' # '.$key.': name='.$group->nom;
|
||||
$res=$group->update();
|
||||
|
||||
|
||||
if ($res > 0)
|
||||
{
|
||||
print ' --> Updated group id='.$group->id.' name='.$group->nom;
|
||||
@ -154,7 +159,7 @@ if ($result >= 0)
|
||||
} else { // Group creation
|
||||
print $langs->transnoentities("GroupCreate").' # '.$key.': name='.$group->nom;
|
||||
$res=$group->create();
|
||||
|
||||
|
||||
if ($res > 0)
|
||||
{
|
||||
print ' --> Created group id='.$group->id.' name='.$group->nom;
|
||||
@ -168,7 +173,7 @@ if ($result >= 0)
|
||||
}
|
||||
|
||||
//print_r($group);
|
||||
|
||||
|
||||
// Gestion des utilisateurs associés au groupe
|
||||
// 1 - Association des utilisateurs du groupe LDAP au groupe Dolibarr
|
||||
$userList = array();
|
||||
@ -179,29 +184,29 @@ if ($result >= 0)
|
||||
$userFilter = explode(',', $userdn);
|
||||
$userKey = $ldap->getAttributeValues('('.$userFilter[0].')', $conf->global->LDAP_KEY_USERS);
|
||||
if(!is_array($userKey)) continue;
|
||||
|
||||
|
||||
$fuser = new User($db);
|
||||
|
||||
|
||||
if($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_SID) {
|
||||
$fuser->fetch('','',$userKey[0]); // Chargement du user concerné par le SID
|
||||
} else if($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_LOGIN) {
|
||||
$fuser->fetch('',$userKey[0]); // Chargement du user concerné par le login
|
||||
}
|
||||
|
||||
|
||||
$userList[$userdn] = $fuser;
|
||||
} else {
|
||||
$fuser = &$userList[$userdn];
|
||||
}
|
||||
|
||||
|
||||
$userIdList[$userdn] = $fuser->id;
|
||||
|
||||
|
||||
// Ajout de l'utilisateur dans le groupe
|
||||
if(!in_array($fuser->id, array_keys($group->members))) {
|
||||
$fuser->SetInGroup($group->id, $group->entity);
|
||||
echo $fuser->login.' added'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 2 - Suppression des utilisateurs du groupe Dolibarr qui ne sont plus dans le groupe LDAP
|
||||
foreach ($group->members as $guser) {
|
||||
if(!in_array($guser->id, $userIdList)) {
|
||||
|
||||
@ -40,17 +40,21 @@ if (! isset($argv[1]) || ! $argv[1]) {
|
||||
}
|
||||
$now=$argv[1];
|
||||
|
||||
// Recupere env dolibarr
|
||||
$version='1.13';
|
||||
|
||||
require_once($path."../../htdocs/master.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php");
|
||||
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
|
||||
|
||||
print "***** $script_file ($version) *****\n";
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
/*
|
||||
if (! $conf->global->LDAP_SYNCHRO_ACTIVE)
|
||||
|
||||
@ -34,23 +34,27 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once($path."../../htdocs/master.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php");
|
||||
|
||||
$langs->load("main");
|
||||
$langs->load("errors");
|
||||
|
||||
|
||||
|
||||
|
||||
// Main
|
||||
|
||||
$version='1.14';
|
||||
@set_time_limit(0);
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
$forcecommit=0;
|
||||
|
||||
require_once($path."../../htdocs/master.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php");
|
||||
|
||||
$langs->load("main");
|
||||
$langs->load("errors");
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
// List of fields to get from LDAP
|
||||
$required_fields = array(
|
||||
@ -178,7 +182,7 @@ if ($result >= 0)
|
||||
foreach ($ldaprecords as $key => $ldapuser)
|
||||
{
|
||||
$fuser = new User($db);
|
||||
|
||||
|
||||
if($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_SID) {
|
||||
$fuser->fetch('','',$ldapuser[$conf->global->LDAP_KEY_USERS]); // Chargement du user concerné par le SID
|
||||
} else if($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_LOGIN) {
|
||||
@ -226,11 +230,11 @@ if ($result >= 0)
|
||||
//if ($fuser->statut > 1) $fuser->statut=1;
|
||||
|
||||
//print_r($ldapuser);
|
||||
|
||||
|
||||
if($fuser->id > 0) { // User update
|
||||
print $langs->transnoentities("UserUpdate").' # '.$key.': login='.$fuser->login.', fullname='.$fuser->getFullName($langs);
|
||||
$res=$fuser->update($user);
|
||||
|
||||
|
||||
if ($res < 0)
|
||||
{
|
||||
$error++;
|
||||
@ -243,7 +247,7 @@ if ($result >= 0)
|
||||
} else { // User creation
|
||||
print $langs->transnoentities("UserCreate").' # '.$key.': login='.$fuser->login.', fullname='.$fuser->getFullName($langs);
|
||||
$res=$fuser->create($user);
|
||||
|
||||
|
||||
if ($res > 0)
|
||||
{
|
||||
print ' --> Created user id='.$fuser->id.' login='.$fuser->login;
|
||||
@ -256,7 +260,7 @@ if ($result >= 0)
|
||||
}
|
||||
print "\n";
|
||||
//print_r($fuser);
|
||||
|
||||
|
||||
// Gestion des groupes
|
||||
// TODO : revoir la gestion des groupes (ou script de sync groupes)
|
||||
/*if(!$error) {
|
||||
|
||||
@ -34,16 +34,23 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere env dolibarr
|
||||
$version='1.6';
|
||||
|
||||
require_once($path."../../htdocs/master.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/compta/prelevement/class/bonprelevement.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/compta/paiement/class/paiement.class.php");
|
||||
|
||||
$error = 0;
|
||||
// Global variables
|
||||
$version=DOL_VERSION;
|
||||
$error=0;
|
||||
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
@set_time_limit(0);
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
|
||||
$datetimeprev = time();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user