From 098dc08169d1efdd669aebc464d31555fe67c725 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 20 Dec 2016 07:29:49 +0100 Subject: [PATCH 1/4] Loan : Complete work on dol_banner --- htdocs/core/lib/functions.lib.php | 9 +- htdocs/loan/card.php | 153 +++++++++++++++++++----------- htdocs/loan/class/loan.class.php | 10 +- htdocs/loan/document.php | 84 +++++----------- htdocs/loan/info.php | 45 +++++---- htdocs/loan/note.php | 34 ++++--- 6 files changed, 182 insertions(+), 153 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9b37c9c29e3..98dc7f14fd4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1071,6 +1071,12 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye); $morehtmlstatus.=$tmptxt; } + elseif ($object->element == 'loan') + { + $tmptxt=$object->getLibStatut(6, $object->totalpaye); + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye); + $morehtmlstatus.=$tmptxt; + } elseif ($object->element == 'contrat') { if ($object->statut==0) $morehtmlstatus.=$object->getLibStatut(2); @@ -1082,7 +1088,8 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r $morehtmlstatus.=$tmptxt; } if (! empty($object->name_alias)) $morehtmlref.='
'.$object->name_alias.'
'; // For thirdparty - if (! empty($object->label)) $morehtmlref.='
'.$object->label.'
'; // For product + if ($object->element == 'product' && ! empty($object->label)) $morehtmlref.='
'.$object->label.'
'; + if ($object->element != 'product') { $morehtmlref.='
'; diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index be04b806b1f..6dd6b17ccff 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2016 Alexandre Spangaro * Copyright (C) 2015 Frederic France * * This program is free software; you can redistribute it and/or modify @@ -86,8 +86,9 @@ if ($action == 'add' && $user->rights->loan->write) { if (! $cancel) { - $datestart=@dol_mktime(12,0,0, $_POST["startmonth"], $_POST["startday"], $_POST["startyear"]); - $dateend=@dol_mktime(12,0,0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); + $datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int')); + $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int')); + $capital = price2num(GETPOST('capital')); if (! $datestart) { @@ -99,20 +100,20 @@ if ($action == 'add' && $user->rights->loan->write) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateEnd")), null, 'errors'); $action = 'create'; } - elseif (! $_POST["capital"]) + elseif (! $capital) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); $action = 'create'; } else { - $object->label = $_POST["label"]; - $object->fk_bank = $_POST["accountid"]; - $object->capital = $_POST["capital"]; + $object->label = GETPOST('label'); + $object->fk_bank = GETPOST('accountid'); + $object->capital = $capital; $object->datestart = $datestart; $object->dateend = $dateend; - $object->nbterm = $_POST["nbterm"]; - $object->rate = $_POST["rate"]; + $object->nbterm = GETPOST('nbterm'); + $object->rate = GETPOST('rate'); $object->note_private = GETPOST('note_private'); $object->note_public = GETPOST('note_public'); @@ -147,9 +148,9 @@ else if ($action == 'update' && $user->rights->loan->write) if ($object->fetch($id)) { - $object->label = GETPOST("label"); $object->datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int')); $object->dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int')); + $object->capital = price2num(GETPOST("capital")); $object->nbterm = GETPOST("nbterm"); $object->rate = GETPOST("rate"); } @@ -173,6 +174,14 @@ else if ($action == 'update' && $user->rights->loan->write) } } +if ($action == 'setlabel' && $user->rights->loan->write) +{ + $object->fetch($id); + $result = $object->setValueFrom('label', GETPOST('label'), '', '', 'text', '', $user, 'LOAN_MODIFY'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); +} + /* * View */ @@ -180,8 +189,9 @@ else if ($action == 'update' && $user->rights->loan->write) $form = new Form($db); if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db); -$help_url='EN:Module_Loan|FR:Module_Emprunt'; -llxHeader("",$langs->trans("Loan"),$help_url); +$title = $langs->trans("Loan") . ' - ' . $langs->trans("Card"); +$help_url = 'EN:Module_Loan|FR:Module_Emprunt'; +llxHeader("",$title,$help_url); // Create mode @@ -203,7 +213,7 @@ if ($action == 'create') print ''; // Label - print ''; + print ''; // Bank account if (! empty($conf->banque->enabled)) @@ -243,7 +253,7 @@ if ($action == 'create') // Note Private print ''; print ''; - print ''; print ''; - print ''; - print '
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans('NotePrivate').''; + print ''; $doleditor = new DolEditor('note_private', GETPOST('note_private', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, true, ROWS_6, '90%'); print $doleditor->Create(1); @@ -253,16 +263,11 @@ if ($action == 'create') // Note Public print '
'.$langs->trans('NotePublic').''; + print ''; $doleditor = new DolEditor('note_public', GETPOST('note_public', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, true, ROWS_6, '90%'); print $doleditor->Create(1); print '
'; - - print '
'; - - print ''; // Accountancy if (! empty($conf->accounting->enabled)) { @@ -283,7 +288,7 @@ if ($action == 'create') print ''; - } + } else // For external software { // Accountancy_account_capital @@ -300,15 +305,16 @@ if ($action == 'create') print ''; print ''; - - print '
'; print $formaccountancy->select_account($object->accountancy_account_interest, 'accountancy_account_interest', 1, '', 0, 1); print '
'.$langs->trans("LoanAccountancyInterestCode").''; print '
'; } print ''; - + dol_fiche_end(); - print '
     '; - print '
'; + print '
'; + print ''; + print '     '; + print ''; + print '
'; print ''; } @@ -316,12 +322,15 @@ if ($action == 'create') // View if ($id > 0) { + $object = new Loan($db); $result = $object->fetch($id); if ($result > 0) { $head=loan_prepare_head($object); + $totalpaid = $object->getSumPayment(); + // Confirm for loan if ($action == 'paid') { @@ -345,27 +354,54 @@ if ($id > 0) dol_fiche_head($head, 'card', $langs->trans("Loan"), 0, 'bill'); + $morehtmlref='
'; + // Ref loan + $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); + $morehtmlref.='
'; + + $linkback = '' . $langs->trans("BackToList") . ''; + + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + + print '
'; + print '
'; + print '
'; + print ''; + /* // Ref - print '"; // Label if ($action == 'edit') { - print ''; } else { - print ''; + print ''; } + */ // Capital - print ''; + if ($action == 'edit') + { + print ''; + print ''; + } + else + { + print ''; + } // Date start print ""; @@ -433,25 +469,13 @@ if ($id > 0) print ''; // Status - print ''; + // print ''; print '
'.$langs->trans("Ref").''; + print '
'.$langs->trans("Ref").''; print $form->showrefnav($object,'id'); print "
'.$langs->trans("Label").''; + print '
'.$langs->trans("Label").''; print ''; print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("LoanCapital").''.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("LoanCapital").''; + print '
'.$langs->trans("LoanCapital").''.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).'
".$langs->trans("DateStart")."
'.$langs->trans("Status").''.$object->getLibStatut(4, $totalpaye).'
'.$langs->trans("Status").''.$object->getLibStatut(4, $totalpaye).'
'; - dol_fiche_end(); - - - if ($action == 'edit') - { - print '
'; - print ''; - print '   '; - print ''; - print '
'; - print '

'; - } - - print ''; - print '"; - print "
'; + print ''; + print '
'; + print '
'; /* * Payments @@ -477,14 +501,14 @@ if ($id > 0) $total_insurance = 0; $total_interest = 0; $total_capital = 0; - echo ''; + print '
'; print ''; print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; $var=True; @@ -508,13 +532,13 @@ if ($id > 0) if ($object->paid == 0) { - print ''; - print ''; + print ''; + print ''; $staytopay = $object->capital - $totalpaid; print ''; - print ''; + print ''; } print "
'.$langs->trans("RefPayment").''.$langs->trans("Date").''.$langs->trans("Type").''.$langs->trans("Insurance").''.$langs->trans("Interest").''.$langs->trans("LoanCapital").''.$langs->trans("Insurance").''.$langs->trans("Interest").''.$langs->trans("LoanCapital").'
'.$langs->trans("AlreadyPaid").' :'.price($totalpaid, 0, $langs, 0, 0, -1, $conf->currency).'
'.$langs->trans("AmountExpected").' :'.price($object->capital, 0, $langs, 0, 0, -1, $conf->currency).'
'.$langs->trans("AlreadyPaid").' :'.price($totalpaid, 0, $langs, 0, 0, -1, $conf->currency).'
'.$langs->trans("AmountExpected").' :'.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("RemainderToPay").' :'.price($staytopay, 0, $langs, 0, 0, -1, $conf->currency).'
'.price($staytopay, 0, $langs, 0, 0, -1, $conf->currency).'
"; $db->free($resql); @@ -523,8 +547,25 @@ if ($id > 0) { dol_print_error($db); } - print "
"; + + print '
'; + print '
'; + print '
'; + + print '
'; + + dol_fiche_end(); + + if ($action == 'edit') + { + print '
'; + print ''; + print '     '; + print ''; + print '
'; + } + + if ($action == 'edit') print "\n"; /* * Buttons actions @@ -562,7 +603,7 @@ if ($id > 0) } else { - // Loan not find + // Loan not found dol_print_error('',$object->error); } } diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 3c89f8b36b0..97d90cb31e7 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2016 Alexandre Spangaro * Copyright (C) 2015 Frederic France * * This program is free software; you can redistribute it and/or modify @@ -32,6 +32,7 @@ class Loan extends CommonObject public $element='loan'; public $table='loan'; public $table_element='loan'; + public $picto = 'bill'; public $rowid; public $datestart; @@ -278,6 +279,7 @@ class Loan extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."loan"; $sql.= " SET label='".$this->db->escape($this->label)."',"; + $sql.= " capital='".price2num($this->db->escape($this->capital))."',"; $sql.= " datestart='".$this->db->idate($this->datestart)."',"; $sql.= " dateend='".$this->db->idate($this->dateend)."',"; $sql.= " fk_user_modif = ".$user->id; @@ -378,6 +380,12 @@ class Loan extends CommonObject if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); } + if ($mode == 6) + { + if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); + if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); + if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + } return "Error, mode/status not found"; } diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php index 732d8193638..9a245f17762 100644 --- a/htdocs/loan/document.php +++ b/htdocs/loan/document.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -75,17 +75,33 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; $form = new Form($db); -$help_url='EN:Module_Loan|FR:Module_Emprunt'; -llxHeader("",$langs->trans("Loan"),$help_url); +$title = $langs->trans("Loan") . ' - ' . $langs->trans("Documents"); +$help_url = 'EN:Module_Loan|FR:Module_Emprunt'; +llxHeader("",$title,$help_url); if ($object->id) { - $alreadypayed=$object->getSumPayment(); + $totalpaid=$object->getSumPayment(); $head = loan_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans("Loan"), 0, 'bill'); + $morehtmlref='
'; + // Ref loan + $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); + $morehtmlref.='
'; + + $linkback = '' . $langs->trans("BackToList") . ''; + + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + + print '
'; + print '
'; + // Construit liste des fichiers $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); @@ -97,63 +113,13 @@ if ($object->id) print ''; - - // Ref - print '"; - - // Label - if ($action == 'edit') - { - print ''; - } - else - { - print ''; - } - - // Amount - print ''; - - // Date start - print ""; - print ""; - print ""; - - // Date end - print ""; - print ""; - print ""; - - // Status - print ''; - - print ''; + print ''; print ''; - print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object,'id'); - print "
'.$langs->trans("Label").''; - print ''; - print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("LoanCapital").''.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).'
".$langs->trans("DateStart").""; - if ($action == 'edit') - { - print $form->select_date($object->datestart, 'start', 0, 0, 0, 'loan', 1, 0, 1); - } - else - { - print dol_print_date($object->datestart,"day"); - } - print "
".$langs->trans("DateEnd").""; - if ($action == 'edit') - { - print $form->select_date($object->dateend, 'end', 0, 0, 0, 'loan', 1, 0, 1); - } - else - { - print dol_print_date($object->dateend,"day"); - } - print "
'.$langs->trans("Status").''.$object->getLibStatut(4,$alreadypayed).'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + print "\n"; - print '
'; + print "\n"; + + dol_fiche_end(); $modulepart = 'loan'; $permission = $user->rights->loan->write; diff --git a/htdocs/loan/info.php b/htdocs/loan/info.php index 83fab095d17..55f2c2257bb 100644 --- a/htdocs/loan/info.php +++ b/htdocs/loan/info.php @@ -43,29 +43,38 @@ $result = restrictedArea($user, 'loan', $id, '',''); * View */ -$help_url='EN:Module_Loan|FR:Module_Emprunt'; -llxHeader("",$langs->trans("Loan"),$help_url); +$title = $langs->trans("Loan") . ' - ' . $langs->trans("Info"); +$help_url = 'EN:Module_Loan|FR:Module_Emprunt'; +llxHeader("",$title,$help_url); -if ($id > 0) { - $loan = new Loan($db); - $loan->fetch($id); - $loan->info($id); +$object = new Loan($db); +$object->fetch($id); +$object->info($id); - $head = loan_prepare_head($loan); +$head = loan_prepare_head($object); - dol_fiche_head($head, 'info', $langs->trans("Loan"), 0, 'bill'); +dol_fiche_head($head, 'info', $langs->trans("Loan"), 0, 'bill'); - print '
'; - dol_print_object_info($loan); - print '
'; +$morehtmlref='
'; +// Ref loan +$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); +$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); +$morehtmlref.='
'; - print ''; -} -else -{ - // $id ? -} +$linkback = '' . $langs->trans("BackToList") . ''; + +$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + +dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + +print '
'; +print '
'; + +print '
'; +dol_print_object_info($object); +print '
'; + +print '
'; llxFooter(); - $db->close(); diff --git a/htdocs/loan/note.php b/htdocs/loan/note.php index 155dacf460b..b03880a832e 100644 --- a/htdocs/loan/note.php +++ b/htdocs/loan/note.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2015 Frederic France + * Copyright (C) 2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,8 +22,8 @@ /** * \file htdocs/loan/note.php - * \brief Tab for notes on loan * \ingroup loan + * \brief Tab for notes on loan */ require '../main.inc.php'; @@ -56,43 +57,40 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, $form = new Form($db); -llxHeader('',$langs->trans("Loan"),''); +$title = $langs->trans("Loan") . ' - ' . $langs->trans("Notes"); +$help_url = 'EN:Module_Loan|FR:Module_Emprunt'; +llxHeader("",$title,$help_url); if ($id > 0) { /* * Affichage onglets */ + $totalpaid=$object->getSumPayment(); $head = loan_prepare_head($object); dol_fiche_head($head, 'note', $langs->trans("Loan"), 0, 'bill'); + $morehtmlref='
'; + // Ref loan + $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); + $morehtmlref.='
'; - print '
'; - print ''; + $linkback = '' . $langs->trans("BackToList") . ''; - print ''; + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status - // Ref - print ''; - print ''; - // Name - print ''; - print ''; + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); - print "
'.$langs->trans('Ref').''; - print $form->showrefnav($object,'id','',1,'rowid','ref'); - print '
'.$langs->trans("Name").''.$object->label.'
"; + print '
'; + print '
'; - print '
'; - - //$colwidth='25'; $cssclass='titlefield'; $permission = $user->rights->loan->write; // Used by the include of notes.tpl.php include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - dol_fiche_end(); } From e9765c5190b51c46e2964c43fea819ba024d3bf7 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 20 Dec 2016 07:33:03 +0100 Subject: [PATCH 2/4] Remove colspan --- htdocs/loan/document.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php index 9a245f17762..575be293de0 100644 --- a/htdocs/loan/document.php +++ b/htdocs/loan/document.php @@ -113,8 +113,8 @@ if ($object->id) print ''; - print ''; - print ''; + print ''; + print ''; print "
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
\n"; print "
\n"; From eb2d85ab7812ccfcdcf12380b6556c47f9e3ca92 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 20 Dec 2016 21:39:42 +0100 Subject: [PATCH 3/4] Donation : Complete work on dol_banner & Fix project selector --- htdocs/don/card.php | 15 ++++-- htdocs/don/class/don.class.php | 4 +- htdocs/don/document.php | 10 +++- htdocs/don/info.php | 98 ++++++++++++++++++++++++++++------ htdocs/don/note.php | 80 ++++++++++++++++++++------- 5 files changed, 162 insertions(+), 45 deletions(-) diff --git a/htdocs/don/card.php b/htdocs/don/card.php index fd68b028254..0ace5c88e76 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -49,7 +49,7 @@ $action=GETPOST('action','alpha'); $cancel=GETPOST('cancel'); $amount=GETPOST('amount'); $donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); -$projectid=GETPOST('projectid')?GETPOST('projectid','int'):GETPOST("fk_projet",'int'); +$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); $object = new Don($db); $extrafields = new ExtraFields($db); @@ -109,7 +109,7 @@ if ($action == 'update') $object->email = GETPOST("email"); $object->date = $donation_date; $object->public = GETPOST("public"); - $object->fk_projet = GETPOST("fk_projet"); + $object->fk_project = GETPOST("fk_project"); $object->note_private= GETPOST("note_private"); $object->note_public = GETPOST("note_public"); @@ -164,7 +164,7 @@ if ($action == 'add') $object->note_private= GETPOST("note_private"); $object->note_public = GETPOST("note_public"); $object->public = GETPOST("public"); - $object->fk_projet = GETPOST("fk_projet"); + $object->fk_project = GETPOST("fk_project"); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -230,6 +230,11 @@ if ($action == 'set_paid') setEventMessages($object->error, $object->errors, 'errors'); } } +else if ($action == 'classin' && $user->rights->don->creer) +{ + $object->fetch($id); + $object->setProject($projectid); +} // Remove file in doc form if ($action == 'remove_file') { @@ -361,7 +366,7 @@ if ($action == 'create') if (! empty($conf->projet->enabled)) { print "".$langs->trans("Project").""; - $formproject->select_projects(-1, $projectid,'fk_projet', 0, 0, 1, 1); + $formproject->select_projects(-1, $projectid,'fk_project', 0, 0, 1, 1); print "\n"; } @@ -486,7 +491,7 @@ if (! empty($id) && $action == 'edit') $langs->load('projects'); print ''.$langs->trans('Project').''; - $formproject->select_projects(-1, $object->fk_projet,'fk_projet', 0, 0, 1, 1); + $formproject->select_projects(-1, $object->fk_project,'fk_project', 0, 0, 1, 1); print ''; } diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 820c2f9d1b4..d7e4d84baab 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -363,7 +363,7 @@ class Don extends CommonObject $sql.= ", '".$this->db->escape($this->town)."'"; $sql.= ", ".$this->country_id; $sql.= ", ".$this->public; - $sql.= ", ".($this->fk_projet > 0?$this->fk_projet:"null"); + $sql.= ", ".($this->fk_project > 0?$this->fk_project:"null"); $sql.= ", ".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL"); $sql.= ", ".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL"); $sql.= ", ".$user->id; @@ -459,7 +459,7 @@ class Don extends CommonObject $sql .= ",town='".$this->db->escape($this->town)."'"; $sql .= ",fk_country = ".$this->country_id; $sql .= ",public=".$this->public; - $sql .= ",fk_projet=".($this->fk_projet>0?$this->fk_projet:'null'); + $sql .= ",fk_projet=".($this->fk_project>0?$this->fk_project:'null'); $sql .= ",note_private=".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL"); $sql .= ",note_public=".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL"); $sql .= ",datedon='".$this->db->idate($this->date)."'"; diff --git a/htdocs/don/document.php b/htdocs/don/document.php index ff25ca2828d..9a253bf57be 100644 --- a/htdocs/don/document.php +++ b/htdocs/don/document.php @@ -48,6 +48,7 @@ $id = GETPOST('id','int'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action','alpha'); $confirm = GETPOST('confirm','alpha'); +$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); // Security check if ($user->societe_id) $socid=$user->societe_id; @@ -79,6 +80,11 @@ $modulepart='don'; include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +if ($action == 'classin' && $user->rights->don->creer) +{ + $object->fetch($id); + $object->setProject($projectid); +} /* * View @@ -87,7 +93,9 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; $form = new Form($db); if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } -llxHeader("",$langs->trans("Donation")); +$title = $langs->trans('Donation') . " - " . $langs->trans('Documents'); +$helpurl = ""; +llxHeader('', $title, $helpurl); if ($object->id) diff --git a/htdocs/don/info.php b/htdocs/don/info.php index 6e7bce98b4c..96310e010f5 100644 --- a/htdocs/don/info.php +++ b/htdocs/don/info.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2015-2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,37 +25,101 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +if (! empty($conf->projet->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +} $langs->load("donations"); -// Security check $id = GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); +$action=GETPOST('action','alpha'); +$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); + +// Security check if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'don', $id, ''); +$object = new Don($db); +$object->fetch($id); +/* + * Actions + */ +if ($action == 'classin' && $user->rights->don->creer) +{ + $object->fetch($id); + $object->setProject($projectid); +} /* * View */ +$title = $langs->trans('Donation') . " - " . $langs->trans('Info'); +$helpurl = ""; +llxHeader('', $title, $helpurl); -llxHeader("",$langs->trans("Donation")); +$form = new Form($db); +if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } -if ($id) +$object->info($id); + +$head = donation_prepare_head($object); + +dol_fiche_head($head, 'info', $langs->trans("Donation"), 0, 'generic'); + +$linkback = ''.$langs->trans("BackToList").''; + +$morehtmlref='
'; +// Project +if (! empty($conf->projet->enabled)) { - $object = new Don($db); - $object->fetch($id); - $object->info($id); - - $head = donation_prepare_head($object); - - dol_fiche_head($head, 'info', $langs->trans("Donation"), 0, 'generic'); - - print '
'; - dol_print_object_info($object); - print '
'; - - print '
'; + $langs->load("projects"); + $morehtmlref.=$langs->trans('Project') . ' '; + if ($user->rights->don->creer) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } } +$morehtmlref.=''; + +dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); + +print '
'; +print '
'; + +print '
'; + +print '
'; +dol_print_object_info($object); +print '
'; + +print '
'; + +dol_fiche_end(); llxFooter(); $db->close(); diff --git a/htdocs/don/note.php b/htdocs/don/note.php index 22d02fddb01..1ed3e1a2f1d 100644 --- a/htdocs/don/note.php +++ b/htdocs/don/note.php @@ -2,7 +2,8 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,15 +20,20 @@ */ /** - * \file htdocs/compta/facture/note.php - * \ingroup facture - * \brief Fiche de notes sur une facture + * \file htdocs/don/note.php + * \ingroup donations + * \brief Page to show a donation notes */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +if (! empty($conf->projet->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +} $langs->load("companies"); $langs->load("bills"); @@ -36,6 +42,7 @@ $langs->load("donations"); $id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility $ref=GETPOST('ref','alpha'); $action=GETPOST('action','alpha'); +$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); // Security check $socid=0; @@ -51,10 +58,13 @@ $permissionnote=$user->rights->don->creer; // Used by the include of actions_set /* * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once - - +if ($action == 'classin' && $user->rights->don->creer) +{ + $object->fetch($id); + $object->setProject($projectid); +} /* * View @@ -65,35 +75,65 @@ $helpurl = ""; llxHeader('', $title, $helpurl); $form = new Form($db); +if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } if ($id > 0 || ! empty($ref)) { $object = new Don($db); $object->fetch($id,$ref); - $head = donation_prepare_head($object); + $head = donation_prepare_head($object); - dol_fiche_head($head, 'note', $langs->trans("Donation"), 0, 'generic'); - - $linkback = ''.$langs->trans("BackToList").''; - - print ''; + dol_fiche_head($head, 'note', $langs->trans("Donation"), 0, 'generic'); - // Ref - print ''; + $linkback = ''.$langs->trans("BackToList").''; - print "
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', ''); - print '
"; + $morehtmlref='
'; + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.=$langs->trans('Project') . ' '; + if ($user->rights->don->creer) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.='
'; - print '
'; + dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); + print '
'; + print '
'; + + $cssclass="titlefield"; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; dol_fiche_end(); } - llxFooter(); $db->close(); From c187f95269e72d8bd6d3d6e85a526054adca8d4d Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 20 Dec 2016 21:59:05 +0100 Subject: [PATCH 4/4] Social contribution : Complete work on dol_banner --- htdocs/compta/sociales/card.php | 3 +- htdocs/compta/sociales/document.php | 81 ++++++++++------------------- htdocs/compta/sociales/info.php | 43 ++++++++++++--- 3 files changed, 65 insertions(+), 62 deletions(-) diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 3816fa6ee58..e917e1e1c71 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -269,8 +269,9 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char $form = new Form($db); $formsocialcontrib = new FormSocialContrib($db); +$title = $langs->trans("SocialContribution") . ' - ' . $langs->trans("Card"); $help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)'; -llxHeader("",$langs->trans("SocialContribution"),$help_url); +llxHeader("",$title,$help_url); // Mode creation diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index 926e6232581..a6f4bc10daf 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -75,6 +75,13 @@ $modulepart='tax'; include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +if ($action == 'setlib' && $user->rights->tax->charges->creer) +{ + $object->fetch($id); + $result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); +} /* * View @@ -82,8 +89,9 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; $form = new Form($db); +$title = $langs->trans("SocialContribution") . ' - ' . $langs->trans("Documents"); $help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)'; -llxHeader("",$langs->trans("SocialContribution"),$help_url); +llxHeader("",$title,$help_url); if ($object->id) { @@ -93,6 +101,20 @@ if ($object->id) dol_fiche_head($head, 'documents', $langs->trans("SocialContribution"), 0, 'bill'); + $morehtmlref='
'; + // Label of social contribution + $morehtmlref.=$form->editfieldkey("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); + $morehtmlref.='
'; + + $linkback = '' . $langs->trans("BackToList") . ''; + + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + + print '
'; + print '
'; // Construit liste des fichiers $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); @@ -105,62 +127,15 @@ if ($object->id) print ''; - // Ref - print '"; - - // Label - if ($action == 'edit') - { - print ''; - } - else - { - print ''; - } - - // Type - print ""; - - // Period end date - print ""; - print ""; - print ""; - - // Due date - if ($action == 'edit') - { - print '"; - } - else { - print ""; - } - - // Amount - print ''; - - // Status - print ''; - - print ''; + print ''; print ''; print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object,'id'); - print "
'.$langs->trans("Label").''; - print ''; - print '
'.$langs->trans("Label").''.$object->lib.'
".$langs->trans("Type")."".$object->type_libelle."
".$langs->trans("PeriodEndDate").""; - if ($action == 'edit') - { - print $form->select_date($object->periode, 'period', 0, 0, 0, 'charge', 1); - } - else - { - print dol_print_date($object->periode,"day"); - } - print "
'.$langs->trans("DateDue").""; - print $form->select_date($object->date_ech, 'ech', 0, 0, 0, 'charge', 1); - print "
".$langs->trans("DateDue")."".dol_print_date($object->date_ech,'day')."
'.$langs->trans("AmountTTC").''.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("Status").''.$object->getLibStatut(4,$alreadypayed).'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; print '
'; + + print '
'; + + dol_fiche_end(); $modulepart = 'tax'; $permission = $user->rights->tax->charges->creer; diff --git a/htdocs/compta/sociales/info.php b/htdocs/compta/sociales/info.php index c41787b7d08..ff905f1ee6c 100644 --- a/htdocs/compta/sociales/info.php +++ b/htdocs/compta/sociales/info.php @@ -37,25 +37,52 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', $id, 'chargesociales','charges'); +/* + * Actions + */ + +if ($action == 'setlib' && $user->rights->tax->charges->creer) +{ + $object->fetch($id); + $result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); +} /* * View */ +$title = $langs->trans("SocialContribution") . ' - ' . $langs->trans("Info"); +$help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)'; +llxHeader("",$title,$help_url); -$help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)'; -llxHeader("",$langs->trans("SocialContribution"),$help_url); +$object = new ChargeSociales($db); +$object->fetch($id); +$object->info($id); -$chargesociales = new ChargeSociales($db); -$chargesociales->fetch($id); -$chargesociales->info($id); - -$head = tax_prepare_head($chargesociales); +$head = tax_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("SocialContribution"), 0, 'bill'); +$morehtmlref='
'; +// Label of social contribution +$morehtmlref.=$form->editfieldkey("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); +$morehtmlref.=$form->editfieldval("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); +$morehtmlref.='
'; + +$linkback = '' . $langs->trans("BackToList") . ''; + +$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + +dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + +print '
'; +print '
'; + +print '
'; print '
'; -dol_print_object_info($chargesociales); +dol_print_object_info($object); print '
'; print '
';