@@ -30,41 +30,41 @@ |
||
30 | 30 | // Set public note |
31 | 31 | if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel','alpha')) |
32 | 32 | { |
33 | - if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
34 | - if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
33 | + if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
34 | + if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
35 | 35 | |
36 | - $result_update=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public'); |
|
36 | + $result_update=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public'); |
|
37 | 37 | |
38 | - if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
39 | - elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) |
|
40 | - { |
|
41 | - // Define output language |
|
42 | - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) |
|
43 | - { |
|
44 | - $outputlangs = $langs; |
|
45 | - $newlang = ''; |
|
46 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
47 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
48 | - if (! empty($newlang)) { |
|
49 | - $outputlangs = new Translate("", $conf); |
|
50 | - $outputlangs->setDefaultLang($newlang); |
|
51 | - } |
|
52 | - $model=$object->modelpdf; |
|
53 | - $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); |
|
54 | - $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); |
|
55 | - $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); |
|
38 | + if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
39 | + elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) |
|
40 | + { |
|
41 | + // Define output language |
|
42 | + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) |
|
43 | + { |
|
44 | + $outputlangs = $langs; |
|
45 | + $newlang = ''; |
|
46 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
47 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
48 | + if (! empty($newlang)) { |
|
49 | + $outputlangs = new Translate("", $conf); |
|
50 | + $outputlangs->setDefaultLang($newlang); |
|
51 | + } |
|
52 | + $model=$object->modelpdf; |
|
53 | + $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); |
|
54 | + $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); |
|
55 | + $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); |
|
56 | 56 | |
57 | - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
57 | + $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
58 | 58 | |
59 | - if ($result < 0) dol_print_error($db,$result); |
|
60 | - } |
|
61 | - } |
|
59 | + if ($result < 0) dol_print_error($db,$result); |
|
60 | + } |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | // Set public note |
64 | 64 | else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('cancel','alpha')) |
65 | 65 | { |
66 | - if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
67 | - if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
68 | - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private', 'none'), ENT_QUOTES),'_private'); |
|
69 | - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
66 | + if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
67 | + if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
68 | + $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private', 'none'), ENT_QUOTES),'_private'); |
|
69 | + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
70 | 70 | } |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | // $id must be defined (object is loaded in this file with fetch) |
29 | 29 | |
30 | 30 | // Set public note |
31 | -if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel','alpha')) |
|
31 | +if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', 'alpha')) |
|
32 | 32 | { |
33 | - if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
34 | - if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
33 | + if (empty($action) || !is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
34 | + if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
35 | 35 | |
36 | - $result_update=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public'); |
|
36 | + $result_update = $object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES), '_public'); |
|
37 | 37 | |
38 | 38 | if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors'); |
39 | 39 | elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) |
@@ -43,28 +43,28 @@ discard block |
||
43 | 43 | { |
44 | 44 | $outputlangs = $langs; |
45 | 45 | $newlang = ''; |
46 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
46 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); |
|
47 | 47 | if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
48 | - if (! empty($newlang)) { |
|
48 | + if (!empty($newlang)) { |
|
49 | 49 | $outputlangs = new Translate("", $conf); |
50 | 50 | $outputlangs->setDefaultLang($newlang); |
51 | 51 | } |
52 | - $model=$object->modelpdf; |
|
53 | - $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); |
|
54 | - $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); |
|
55 | - $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); |
|
52 | + $model = $object->modelpdf; |
|
53 | + $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); |
|
54 | + $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); |
|
55 | + $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); |
|
56 | 56 | |
57 | - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
57 | + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
58 | 58 | |
59 | - if ($result < 0) dol_print_error($db,$result); |
|
59 | + if ($result < 0) dol_print_error($db, $result); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | } |
63 | 63 | // Set public note |
64 | -else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('cancel','alpha')) |
|
64 | +else if ($action == 'setnote_private' && !empty($permissionnote) && !GETPOST('cancel', 'alpha')) |
|
65 | 65 | { |
66 | - if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
67 | - if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
68 | - $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private', 'none'), ENT_QUOTES),'_private'); |
|
66 | + if (empty($action) || !is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
67 | + if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
68 | + $result = $object->update_note(dol_html_entity_decode(GETPOST('note_private', 'none'), ENT_QUOTES), '_private'); |
|
69 | 69 | if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
70 | 70 | } |
@@ -30,21 +30,31 @@ discard block |
||
30 | 30 | // Set public note |
31 | 31 | if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel','alpha')) |
32 | 32 | { |
33 | - if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
34 | - if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
33 | + if (empty($action) || ! is_object($object) || empty($id)) { |
|
34 | + dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
35 | + } |
|
36 | + if (empty($object->id)) { |
|
37 | + $object->fetch($id); |
|
38 | + } |
|
39 | + // Fetch may not be already done |
|
35 | 40 | |
36 | 41 | $result_update=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public'); |
37 | 42 | |
38 | - if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
39 | - elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) |
|
43 | + if ($result_update < 0) { |
|
44 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
45 | + } elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) |
|
40 | 46 | { |
41 | 47 | // Define output language |
42 | 48 | if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) |
43 | 49 | { |
44 | 50 | $outputlangs = $langs; |
45 | 51 | $newlang = ''; |
46 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); |
|
47 | - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
52 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) { |
|
53 | + $newlang = GETPOST('lang_id','aZ09'); |
|
54 | + } |
|
55 | + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { |
|
56 | + $newlang = $object->thirdparty->default_lang; |
|
57 | + } |
|
48 | 58 | if (! empty($newlang)) { |
49 | 59 | $outputlangs = new Translate("", $conf); |
50 | 60 | $outputlangs->setDefaultLang($newlang); |
@@ -56,15 +66,24 @@ discard block |
||
56 | 66 | |
57 | 67 | $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); |
58 | 68 | |
59 | - if ($result < 0) dol_print_error($db,$result); |
|
69 | + if ($result < 0) { |
|
70 | + dol_print_error($db,$result); |
|
71 | + } |
|
60 | 72 | } |
61 | 73 | } |
62 | 74 | } |
63 | 75 | // Set public note |
64 | 76 | else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('cancel','alpha')) |
65 | 77 | { |
66 | - if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
67 | - if (empty($object->id)) $object->fetch($id); // Fetch may not be already done |
|
78 | + if (empty($action) || ! is_object($object) || empty($id)) { |
|
79 | + dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); |
|
80 | + } |
|
81 | + if (empty($object->id)) { |
|
82 | + $object->fetch($id); |
|
83 | + } |
|
84 | + // Fetch may not be already done |
|
68 | 85 | $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private', 'none'), ENT_QUOTES),'_private'); |
69 | - if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); |
|
70 | -} |
|
86 | + if ($result < 0) { |
|
87 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
88 | + } |
|
89 | + } |
@@ -43,79 +43,79 @@ discard block |
||
43 | 43 | $accessallowed=0; |
44 | 44 | if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service') |
45 | 45 | { |
46 | - $result=restrictedArea($user,'produit|service',$id,'product&product'); |
|
47 | - if ($modulepart=='produit|service' && (! $user->rights->produit->lire && ! $user->rights->service->lire)) accessforbidden(); |
|
48 | - $accessallowed=1; |
|
46 | + $result=restrictedArea($user,'produit|service',$id,'product&product'); |
|
47 | + if ($modulepart=='produit|service' && (! $user->rights->produit->lire && ! $user->rights->service->lire)) accessforbidden(); |
|
48 | + $accessallowed=1; |
|
49 | 49 | } |
50 | 50 | elseif ($modulepart == 'project') |
51 | 51 | { |
52 | 52 | $result=restrictedArea($user,'projet',$id); |
53 | - if (! $user->rights->projet->lire) accessforbidden(); |
|
54 | - $accessallowed=1; |
|
53 | + if (! $user->rights->projet->lire) accessforbidden(); |
|
54 | + $accessallowed=1; |
|
55 | 55 | } |
56 | 56 | elseif ($modulepart == 'expensereport') |
57 | 57 | { |
58 | - $result=restrictedArea($user,'expensereport',$id,'expensereport'); |
|
59 | - if (! $user->rights->expensereport->lire) accessforbidden(); |
|
60 | - $accessallowed=1; |
|
58 | + $result=restrictedArea($user,'expensereport',$id,'expensereport'); |
|
59 | + if (! $user->rights->expensereport->lire) accessforbidden(); |
|
60 | + $accessallowed=1; |
|
61 | 61 | } |
62 | 62 | elseif ($modulepart == 'holiday') |
63 | 63 | { |
64 | - $result=restrictedArea($user,'holiday',$id,'holiday'); |
|
65 | - if (! $user->rights->holiday->read) accessforbidden(); |
|
66 | - $accessallowed=1; |
|
64 | + $result=restrictedArea($user,'holiday',$id,'holiday'); |
|
65 | + if (! $user->rights->holiday->read) accessforbidden(); |
|
66 | + $accessallowed=1; |
|
67 | 67 | } |
68 | 68 | elseif ($modulepart == 'member') |
69 | 69 | { |
70 | - $result=restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid'); |
|
71 | - if (! $user->rights->adherent->lire) accessforbidden(); |
|
72 | - $accessallowed=1; |
|
70 | + $result=restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid'); |
|
71 | + if (! $user->rights->adherent->lire) accessforbidden(); |
|
72 | + $accessallowed=1; |
|
73 | 73 | } |
74 | 74 | elseif ($modulepart == 'user') |
75 | 75 | { |
76 | - $result=restrictedArea($user,'user',$id,'user'); |
|
77 | - if (! $user->rights->user->user->lire) accessforbidden(); |
|
78 | - $accessallowed=1; |
|
76 | + $result=restrictedArea($user,'user',$id,'user'); |
|
77 | + if (! $user->rights->user->user->lire) accessforbidden(); |
|
78 | + $accessallowed=1; |
|
79 | 79 | } |
80 | 80 | elseif ($modulepart == 'societe') |
81 | 81 | { |
82 | - $result=restrictedArea($user,'societe',$id,'societe'); |
|
83 | - if (! $user->rights->societe->lire) accessforbidden(); |
|
84 | - $accessallowed=1; |
|
82 | + $result=restrictedArea($user,'societe',$id,'societe'); |
|
83 | + if (! $user->rights->societe->lire) accessforbidden(); |
|
84 | + $accessallowed=1; |
|
85 | 85 | } |
86 | 86 | elseif ($modulepart == 'tax') |
87 | 87 | { |
88 | - $result=restrictedArea($user, 'tax', $id, 'chargesociales','charges'); |
|
89 | - if (! $user->rights->tax->charges->lire) accessforbidden(); |
|
90 | - $accessallowed=1; |
|
88 | + $result=restrictedArea($user, 'tax', $id, 'chargesociales','charges'); |
|
89 | + if (! $user->rights->tax->charges->lire) accessforbidden(); |
|
90 | + $accessallowed=1; |
|
91 | 91 | } |
92 | 92 | elseif ($modulepart == 'ticket') |
93 | 93 | { |
94 | - $result=restrictedArea($user,'ticket',$id,'ticket'); |
|
95 | - if (! $user->rights->ticket->read) accessforbidden(); |
|
96 | - $accessallowed=1; |
|
94 | + $result=restrictedArea($user,'ticket',$id,'ticket'); |
|
95 | + if (! $user->rights->ticket->read) accessforbidden(); |
|
96 | + $accessallowed=1; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | // Security: |
100 | 100 | // Limit access if permissions are wrong |
101 | 101 | if (! $accessallowed) |
102 | 102 | { |
103 | - accessforbidden(); |
|
103 | + accessforbidden(); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | // Define dir according to modulepart |
107 | 107 | if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service') |
108 | 108 | { |
109 | - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
|
110 | - $object = new Product($db); |
|
111 | - if ($id > 0) |
|
112 | - { |
|
113 | - $result = $object->fetch($id); |
|
114 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
115 | - $dir=$conf->product->multidir_output[$object->entity]; // By default |
|
116 | - if ($object->type == Product::TYPE_PRODUCT) $dir=$conf->product->multidir_output[$object->entity]; |
|
117 | - if ($object->type == Product::TYPE_SERVICE) $dir=$conf->service->multidir_output[$object->entity]; |
|
118 | - } |
|
109 | + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
|
110 | + $object = new Product($db); |
|
111 | + if ($id > 0) |
|
112 | + { |
|
113 | + $result = $object->fetch($id); |
|
114 | + if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
115 | + $dir=$conf->product->multidir_output[$object->entity]; // By default |
|
116 | + if ($object->type == Product::TYPE_PRODUCT) $dir=$conf->product->multidir_output[$object->entity]; |
|
117 | + if ($object->type == Product::TYPE_SERVICE) $dir=$conf->service->multidir_output[$object->entity]; |
|
118 | + } |
|
119 | 119 | } |
120 | 120 | elseif ($modulepart == 'project') |
121 | 121 | { |
@@ -130,25 +130,25 @@ discard block |
||
130 | 130 | } |
131 | 131 | elseif ($modulepart == 'holiday') |
132 | 132 | { |
133 | - require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; |
|
134 | - $object = new Holiday($db); |
|
135 | - if ($id > 0) |
|
136 | - { |
|
137 | - $result = $object->fetch($id); |
|
138 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
139 | - $dir=$conf->holiday->dir_output; // By default |
|
140 | - } |
|
133 | + require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; |
|
134 | + $object = new Holiday($db); |
|
135 | + if ($id > 0) |
|
136 | + { |
|
137 | + $result = $object->fetch($id); |
|
138 | + if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
139 | + $dir=$conf->holiday->dir_output; // By default |
|
140 | + } |
|
141 | 141 | } |
142 | 142 | elseif ($modulepart == 'member') |
143 | 143 | { |
144 | - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
145 | - $object = new Adherent($db); |
|
146 | - if ($id > 0) |
|
147 | - { |
|
148 | - $result = $object->fetch($id); |
|
149 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
150 | - $dir=$conf->adherent->dir_output; // By default |
|
151 | - } |
|
144 | + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
145 | + $object = new Adherent($db); |
|
146 | + if ($id > 0) |
|
147 | + { |
|
148 | + $result = $object->fetch($id); |
|
149 | + if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
150 | + $dir=$conf->adherent->dir_output; // By default |
|
151 | + } |
|
152 | 152 | } |
153 | 153 | elseif ($modulepart == 'societe') |
154 | 154 | { |
@@ -185,28 +185,28 @@ discard block |
||
185 | 185 | } |
186 | 186 | elseif ($modulepart == 'tax') |
187 | 187 | { |
188 | - require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; |
|
189 | - $object = new ChargeSociales($db); |
|
190 | - if ($id > 0) |
|
191 | - { |
|
192 | - $result = $object->fetch($id); |
|
193 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
194 | - $dir=$conf->tax->dir_output; // By default |
|
195 | - } |
|
188 | + require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; |
|
189 | + $object = new ChargeSociales($db); |
|
190 | + if ($id > 0) |
|
191 | + { |
|
192 | + $result = $object->fetch($id); |
|
193 | + if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
194 | + $dir=$conf->tax->dir_output; // By default |
|
195 | + } |
|
196 | 196 | } |
197 | 197 | elseif ($modulepart == 'ticket') |
198 | 198 | { |
199 | - require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; |
|
200 | - $object = new Ticket($db); |
|
201 | - if ($id > 0) |
|
202 | - { |
|
203 | - $result = $object->fetch($id); |
|
204 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
205 | - $dir=$conf->ticket->dir_output; // By default |
|
206 | - } |
|
199 | + require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; |
|
200 | + $object = new Ticket($db); |
|
201 | + if ($id > 0) |
|
202 | + { |
|
203 | + $result = $object->fetch($id); |
|
204 | + if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
205 | + $dir=$conf->ticket->dir_output; // By default |
|
206 | + } |
|
207 | 207 | } |
208 | 208 | else { |
209 | - print 'Action crop for module part '.$modulepart.' is not supported yet.'; |
|
209 | + print 'Action crop for module part '.$modulepart.' is not supported yet.'; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | if (empty($backtourl)) |
@@ -229,154 +229,154 @@ discard block |
||
229 | 229 | |
230 | 230 | if ($cancel) |
231 | 231 | { |
232 | - if ($backtourl) |
|
233 | - { |
|
234 | - header("Location: ".$backtourl); |
|
235 | - exit; |
|
236 | - } |
|
237 | - else |
|
238 | - { |
|
239 | - dol_print_error('', 'Cancel on photo_resize with a not supported value of modulepart='.$modulepart); |
|
240 | - exit; |
|
241 | - } |
|
232 | + if ($backtourl) |
|
233 | + { |
|
234 | + header("Location: ".$backtourl); |
|
235 | + exit; |
|
236 | + } |
|
237 | + else |
|
238 | + { |
|
239 | + dol_print_error('', 'Cancel on photo_resize with a not supported value of modulepart='.$modulepart); |
|
240 | + exit; |
|
241 | + } |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POST["sizex"]) != "") && (isset($_POST["sizey"]) != "")) |
245 | 245 | { |
246 | - $fullpath=$dir."/".$original_file; |
|
247 | - |
|
248 | - $result=dol_imageResizeOrCrop($fullpath,0,$_POST['sizex'],$_POST['sizey']); |
|
249 | - |
|
250 | - if ($result == $fullpath) |
|
251 | - { |
|
252 | - $object->addThumbs($fullpath); |
|
253 | - |
|
254 | - // Update/create database for file $fullpath |
|
255 | - $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath); |
|
256 | - $rel_filename = preg_replace('/^[\\/]/','',$rel_filename); |
|
257 | - |
|
258 | - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
|
259 | - $ecmfile=new EcmFiles($db); |
|
260 | - $result = $ecmfile->fetch(0, '', $rel_filename); |
|
261 | - if ($result > 0) // If found |
|
262 | - { |
|
263 | - $filename = basename($rel_filename); |
|
264 | - $rel_dir = dirname($rel_filename); |
|
265 | - $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
|
266 | - $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
|
267 | - |
|
268 | - $ecmfile->label = md5_file(dol_osencode($fullpath)); |
|
269 | - $result = $ecmfile->update($user); |
|
270 | - } |
|
271 | - elseif ($result == 0) // If not found |
|
272 | - { |
|
273 | - $filename = basename($rel_filename); |
|
274 | - $rel_dir = dirname($rel_filename); |
|
275 | - $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
|
276 | - $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
|
277 | - |
|
278 | - $ecmfile->filepath = $rel_dir; |
|
279 | - $ecmfile->filename = $filename; |
|
280 | - $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file |
|
281 | - $ecmfile->fullpath_orig = $fullpath; |
|
282 | - $ecmfile->gen_or_uploaded = 'unknown'; |
|
283 | - $ecmfile->description = ''; // indexed content |
|
284 | - $ecmfile->keyword = ''; // keyword content |
|
285 | - $result = $ecmfile->create($user); |
|
286 | - if ($result < 0) |
|
287 | - { |
|
288 | - setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
|
289 | - } |
|
290 | - $result = $ecmfile->create($user); |
|
291 | - } |
|
292 | - |
|
293 | - if ($backtourl) |
|
294 | - { |
|
295 | - header("Location: ".$backtourl); |
|
296 | - exit; |
|
297 | - } |
|
298 | - else |
|
299 | - { |
|
300 | - dol_print_error('', 'confirm_resize on photo_resize without backtourl defined for modulepart='.$modulepart); |
|
301 | - exit; |
|
302 | - } |
|
303 | - } |
|
304 | - else |
|
305 | - { |
|
306 | - setEventMessages($result, null, 'errors'); |
|
307 | - $_GET['file']=$_POST["file"]; |
|
308 | - $action=''; |
|
309 | - } |
|
246 | + $fullpath=$dir."/".$original_file; |
|
247 | + |
|
248 | + $result=dol_imageResizeOrCrop($fullpath,0,$_POST['sizex'],$_POST['sizey']); |
|
249 | + |
|
250 | + if ($result == $fullpath) |
|
251 | + { |
|
252 | + $object->addThumbs($fullpath); |
|
253 | + |
|
254 | + // Update/create database for file $fullpath |
|
255 | + $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath); |
|
256 | + $rel_filename = preg_replace('/^[\\/]/','',$rel_filename); |
|
257 | + |
|
258 | + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
|
259 | + $ecmfile=new EcmFiles($db); |
|
260 | + $result = $ecmfile->fetch(0, '', $rel_filename); |
|
261 | + if ($result > 0) // If found |
|
262 | + { |
|
263 | + $filename = basename($rel_filename); |
|
264 | + $rel_dir = dirname($rel_filename); |
|
265 | + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
|
266 | + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
|
267 | + |
|
268 | + $ecmfile->label = md5_file(dol_osencode($fullpath)); |
|
269 | + $result = $ecmfile->update($user); |
|
270 | + } |
|
271 | + elseif ($result == 0) // If not found |
|
272 | + { |
|
273 | + $filename = basename($rel_filename); |
|
274 | + $rel_dir = dirname($rel_filename); |
|
275 | + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
|
276 | + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
|
277 | + |
|
278 | + $ecmfile->filepath = $rel_dir; |
|
279 | + $ecmfile->filename = $filename; |
|
280 | + $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file |
|
281 | + $ecmfile->fullpath_orig = $fullpath; |
|
282 | + $ecmfile->gen_or_uploaded = 'unknown'; |
|
283 | + $ecmfile->description = ''; // indexed content |
|
284 | + $ecmfile->keyword = ''; // keyword content |
|
285 | + $result = $ecmfile->create($user); |
|
286 | + if ($result < 0) |
|
287 | + { |
|
288 | + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
|
289 | + } |
|
290 | + $result = $ecmfile->create($user); |
|
291 | + } |
|
292 | + |
|
293 | + if ($backtourl) |
|
294 | + { |
|
295 | + header("Location: ".$backtourl); |
|
296 | + exit; |
|
297 | + } |
|
298 | + else |
|
299 | + { |
|
300 | + dol_print_error('', 'confirm_resize on photo_resize without backtourl defined for modulepart='.$modulepart); |
|
301 | + exit; |
|
302 | + } |
|
303 | + } |
|
304 | + else |
|
305 | + { |
|
306 | + setEventMessages($result, null, 'errors'); |
|
307 | + $_GET['file']=$_POST["file"]; |
|
308 | + $action=''; |
|
309 | + } |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | // Crop d'une image |
313 | 313 | if ($action == 'confirm_crop') |
314 | 314 | { |
315 | - $fullpath=$dir."/".$original_file; |
|
316 | - |
|
317 | - //var_dump($_POST['w'].'x'.$_POST['h'].'-'.$_POST['x'].'x'.$_POST['y']);exit; |
|
318 | - $result=dol_imageResizeOrCrop($fullpath,1,$_POST['w'],$_POST['h'],$_POST['x'],$_POST['y']); |
|
319 | - |
|
320 | - if ($result == $fullpath) |
|
321 | - { |
|
322 | - $object->addThumbs($fullpath); |
|
323 | - |
|
324 | - // Update/create database for file $fullpath |
|
325 | - $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath); |
|
326 | - $rel_filename = preg_replace('/^[\\/]/','',$rel_filename); |
|
327 | - |
|
328 | - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
|
329 | - $ecmfile=new EcmFiles($db); |
|
330 | - $result = $ecmfile->fetch(0, '', $rel_filename); |
|
331 | - if ($result > 0) // If found |
|
332 | - { |
|
333 | - $filename = basename($rel_filename); |
|
334 | - $rel_dir = dirname($rel_filename); |
|
335 | - $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
|
336 | - $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
|
337 | - |
|
338 | - $ecmfile->label = md5_file(dol_osencode($fullpath)); |
|
339 | - $result = $ecmfile->update($user); |
|
340 | - } |
|
341 | - elseif ($result == 0) // If not found |
|
342 | - { |
|
343 | - $filename = basename($rel_filename); |
|
344 | - $rel_dir = dirname($rel_filename); |
|
345 | - $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
|
346 | - $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
|
347 | - |
|
348 | - $ecmfile->filepath = $rel_dir; |
|
349 | - $ecmfile->filename = $filename; |
|
350 | - $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file |
|
351 | - $ecmfile->fullpath_orig = $fullpath; |
|
352 | - $ecmfile->gen_or_uploaded = 'unknown'; |
|
353 | - $ecmfile->description = ''; // indexed content |
|
354 | - $ecmfile->keyword = ''; // keyword content |
|
355 | - $result = $ecmfile->create($user); |
|
356 | - if ($result < 0) |
|
357 | - { |
|
358 | - setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
|
359 | - } |
|
360 | - $result = $ecmfile->create($user); |
|
361 | - } |
|
362 | - |
|
363 | - if ($backtourl) |
|
364 | - { |
|
365 | - header("Location: ".$backtourl); |
|
366 | - exit; |
|
367 | - } |
|
368 | - else |
|
369 | - { |
|
370 | - dol_print_error('', 'confirm_crop on photo_resize without backtourl defined for modulepart='.$modulepart); |
|
371 | - exit; |
|
372 | - } |
|
373 | - } |
|
374 | - else |
|
375 | - { |
|
376 | - setEventMessages($result, null, 'errors'); |
|
377 | - $_GET['file']=$_POST["file"]; |
|
378 | - $action=''; |
|
379 | - } |
|
315 | + $fullpath=$dir."/".$original_file; |
|
316 | + |
|
317 | + //var_dump($_POST['w'].'x'.$_POST['h'].'-'.$_POST['x'].'x'.$_POST['y']);exit; |
|
318 | + $result=dol_imageResizeOrCrop($fullpath,1,$_POST['w'],$_POST['h'],$_POST['x'],$_POST['y']); |
|
319 | + |
|
320 | + if ($result == $fullpath) |
|
321 | + { |
|
322 | + $object->addThumbs($fullpath); |
|
323 | + |
|
324 | + // Update/create database for file $fullpath |
|
325 | + $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath); |
|
326 | + $rel_filename = preg_replace('/^[\\/]/','',$rel_filename); |
|
327 | + |
|
328 | + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
|
329 | + $ecmfile=new EcmFiles($db); |
|
330 | + $result = $ecmfile->fetch(0, '', $rel_filename); |
|
331 | + if ($result > 0) // If found |
|
332 | + { |
|
333 | + $filename = basename($rel_filename); |
|
334 | + $rel_dir = dirname($rel_filename); |
|
335 | + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
|
336 | + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
|
337 | + |
|
338 | + $ecmfile->label = md5_file(dol_osencode($fullpath)); |
|
339 | + $result = $ecmfile->update($user); |
|
340 | + } |
|
341 | + elseif ($result == 0) // If not found |
|
342 | + { |
|
343 | + $filename = basename($rel_filename); |
|
344 | + $rel_dir = dirname($rel_filename); |
|
345 | + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
|
346 | + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
|
347 | + |
|
348 | + $ecmfile->filepath = $rel_dir; |
|
349 | + $ecmfile->filename = $filename; |
|
350 | + $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file |
|
351 | + $ecmfile->fullpath_orig = $fullpath; |
|
352 | + $ecmfile->gen_or_uploaded = 'unknown'; |
|
353 | + $ecmfile->description = ''; // indexed content |
|
354 | + $ecmfile->keyword = ''; // keyword content |
|
355 | + $result = $ecmfile->create($user); |
|
356 | + if ($result < 0) |
|
357 | + { |
|
358 | + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
|
359 | + } |
|
360 | + $result = $ecmfile->create($user); |
|
361 | + } |
|
362 | + |
|
363 | + if ($backtourl) |
|
364 | + { |
|
365 | + header("Location: ".$backtourl); |
|
366 | + exit; |
|
367 | + } |
|
368 | + else |
|
369 | + { |
|
370 | + dol_print_error('', 'confirm_crop on photo_resize without backtourl defined for modulepart='.$modulepart); |
|
371 | + exit; |
|
372 | + } |
|
373 | + } |
|
374 | + else |
|
375 | + { |
|
376 | + setEventMessages($result, null, 'errors'); |
|
377 | + $_GET['file']=$_POST["file"]; |
|
378 | + $action=''; |
|
379 | + } |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | |
@@ -433,28 +433,28 @@ discard block |
||
433 | 433 | |
434 | 434 | if (! empty($conf->use_javascript_ajax)) |
435 | 435 | { |
436 | - $infoarray=dol_getImageSize($dir."/".GETPOST("file")); |
|
437 | - $height=$infoarray['height']; |
|
438 | - $width=$infoarray['width']; |
|
439 | - $widthforcrop=$width; $refsizeforcrop='orig'; $ratioforcrop=1; |
|
440 | - // If image is too large, we use another scale. |
|
441 | - if (! empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth']/2))) |
|
442 | - { |
|
443 | - $ratioforcrop=2; |
|
444 | - $widthforcrop=round($_SESSION['dol_screenwidth'] / $ratioforcrop); |
|
445 | - $refsizeforcrop='screenwidth'; |
|
446 | - } |
|
447 | - |
|
448 | - print '<!-- Form to crop -->'."\n"; |
|
449 | - print '<fieldset id="redim_file">'; |
|
450 | - print '<legend>'.$langs->trans("Recenter").'</legend>'; |
|
451 | - print $langs->trans("DefineNewAreaToPick").'...<br>'; |
|
452 | - print '<br><div class="center">'; |
|
453 | - print '<div style="border: 1px solid #888888; width: '.$widthforcrop.'px;">'; |
|
454 | - print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($original_file).'" alt="" id="cropbox" width="'.$widthforcrop.'px"/>'; |
|
455 | - print '</div>'; |
|
456 | - print '</div><br>'; |
|
457 | - print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="POST"> |
|
436 | + $infoarray=dol_getImageSize($dir."/".GETPOST("file")); |
|
437 | + $height=$infoarray['height']; |
|
438 | + $width=$infoarray['width']; |
|
439 | + $widthforcrop=$width; $refsizeforcrop='orig'; $ratioforcrop=1; |
|
440 | + // If image is too large, we use another scale. |
|
441 | + if (! empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth']/2))) |
|
442 | + { |
|
443 | + $ratioforcrop=2; |
|
444 | + $widthforcrop=round($_SESSION['dol_screenwidth'] / $ratioforcrop); |
|
445 | + $refsizeforcrop='screenwidth'; |
|
446 | + } |
|
447 | + |
|
448 | + print '<!-- Form to crop -->'."\n"; |
|
449 | + print '<fieldset id="redim_file">'; |
|
450 | + print '<legend>'.$langs->trans("Recenter").'</legend>'; |
|
451 | + print $langs->trans("DefineNewAreaToPick").'...<br>'; |
|
452 | + print '<br><div class="center">'; |
|
453 | + print '<div style="border: 1px solid #888888; width: '.$widthforcrop.'px;">'; |
|
454 | + print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($original_file).'" alt="" id="cropbox" width="'.$widthforcrop.'px"/>'; |
|
455 | + print '</div>'; |
|
456 | + print '</div><br>'; |
|
457 | + print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="POST"> |
|
458 | 458 | <div class="jc_coords"> |
459 | 459 | '.$langs->trans("NewSizeAfterCropping").': |
460 | 460 | <label>X1 <input type="number" class="flat maxwidth50" id="x" name="x" /></label> |
@@ -477,8 +477,8 @@ discard block |
||
477 | 477 | |
478 | 478 | <input type="submit" id="cancelcrop" name="cancel" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" /> |
479 | 479 | </form>'."\n"; |
480 | - print '</fieldset>'."\n"; |
|
481 | - print '<br>'; |
|
480 | + print '</fieldset>'."\n"; |
|
481 | + print '<br>'; |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | /* Check that mandatory fields are filled */ |
@@ -39,60 +39,72 @@ discard block |
||
39 | 39 | $cancel=GETPOST('cancel','alpha'); |
40 | 40 | |
41 | 41 | // Security check |
42 | -if (empty($modulepart)) accessforbidden('Bad value for modulepart'); |
|
42 | +if (empty($modulepart)) { |
|
43 | + accessforbidden('Bad value for modulepart'); |
|
44 | +} |
|
43 | 45 | $accessallowed=0; |
44 | 46 | if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service') |
45 | 47 | { |
46 | 48 | $result=restrictedArea($user,'produit|service',$id,'product&product'); |
47 | - if ($modulepart=='produit|service' && (! $user->rights->produit->lire && ! $user->rights->service->lire)) accessforbidden(); |
|
49 | + if ($modulepart=='produit|service' && (! $user->rights->produit->lire && ! $user->rights->service->lire)) { |
|
50 | + accessforbidden(); |
|
51 | + } |
|
48 | 52 | $accessallowed=1; |
49 | -} |
|
50 | -elseif ($modulepart == 'project') |
|
53 | +} elseif ($modulepart == 'project') |
|
51 | 54 | { |
52 | 55 | $result=restrictedArea($user,'projet',$id); |
53 | - if (! $user->rights->projet->lire) accessforbidden(); |
|
56 | + if (! $user->rights->projet->lire) { |
|
57 | + accessforbidden(); |
|
58 | + } |
|
54 | 59 | $accessallowed=1; |
55 | -} |
|
56 | -elseif ($modulepart == 'expensereport') |
|
60 | +} elseif ($modulepart == 'expensereport') |
|
57 | 61 | { |
58 | 62 | $result=restrictedArea($user,'expensereport',$id,'expensereport'); |
59 | - if (! $user->rights->expensereport->lire) accessforbidden(); |
|
63 | + if (! $user->rights->expensereport->lire) { |
|
64 | + accessforbidden(); |
|
65 | + } |
|
60 | 66 | $accessallowed=1; |
61 | -} |
|
62 | -elseif ($modulepart == 'holiday') |
|
67 | +} elseif ($modulepart == 'holiday') |
|
63 | 68 | { |
64 | 69 | $result=restrictedArea($user,'holiday',$id,'holiday'); |
65 | - if (! $user->rights->holiday->read) accessforbidden(); |
|
70 | + if (! $user->rights->holiday->read) { |
|
71 | + accessforbidden(); |
|
72 | + } |
|
66 | 73 | $accessallowed=1; |
67 | -} |
|
68 | -elseif ($modulepart == 'member') |
|
74 | +} elseif ($modulepart == 'member') |
|
69 | 75 | { |
70 | 76 | $result=restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid'); |
71 | - if (! $user->rights->adherent->lire) accessforbidden(); |
|
77 | + if (! $user->rights->adherent->lire) { |
|
78 | + accessforbidden(); |
|
79 | + } |
|
72 | 80 | $accessallowed=1; |
73 | -} |
|
74 | -elseif ($modulepart == 'user') |
|
81 | +} elseif ($modulepart == 'user') |
|
75 | 82 | { |
76 | 83 | $result=restrictedArea($user,'user',$id,'user'); |
77 | - if (! $user->rights->user->user->lire) accessforbidden(); |
|
84 | + if (! $user->rights->user->user->lire) { |
|
85 | + accessforbidden(); |
|
86 | + } |
|
78 | 87 | $accessallowed=1; |
79 | -} |
|
80 | -elseif ($modulepart == 'societe') |
|
88 | +} elseif ($modulepart == 'societe') |
|
81 | 89 | { |
82 | 90 | $result=restrictedArea($user,'societe',$id,'societe'); |
83 | - if (! $user->rights->societe->lire) accessforbidden(); |
|
91 | + if (! $user->rights->societe->lire) { |
|
92 | + accessforbidden(); |
|
93 | + } |
|
84 | 94 | $accessallowed=1; |
85 | -} |
|
86 | -elseif ($modulepart == 'tax') |
|
95 | +} elseif ($modulepart == 'tax') |
|
87 | 96 | { |
88 | 97 | $result=restrictedArea($user, 'tax', $id, 'chargesociales','charges'); |
89 | - if (! $user->rights->tax->charges->lire) accessforbidden(); |
|
98 | + if (! $user->rights->tax->charges->lire) { |
|
99 | + accessforbidden(); |
|
100 | + } |
|
90 | 101 | $accessallowed=1; |
91 | -} |
|
92 | -elseif ($modulepart == 'ticket') |
|
102 | +} elseif ($modulepart == 'ticket') |
|
93 | 103 | { |
94 | 104 | $result=restrictedArea($user,'ticket',$id,'ticket'); |
95 | - if (! $user->rights->ticket->read) accessforbidden(); |
|
105 | + if (! $user->rights->ticket->read) { |
|
106 | + accessforbidden(); |
|
107 | + } |
|
96 | 108 | $accessallowed=1; |
97 | 109 | } |
98 | 110 | |
@@ -111,116 +123,139 @@ discard block |
||
111 | 123 | if ($id > 0) |
112 | 124 | { |
113 | 125 | $result = $object->fetch($id); |
114 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
126 | + if ($result <= 0) { |
|
127 | + dol_print_error($db,'Failed to load object'); |
|
128 | + } |
|
115 | 129 | $dir=$conf->product->multidir_output[$object->entity]; // By default |
116 | - if ($object->type == Product::TYPE_PRODUCT) $dir=$conf->product->multidir_output[$object->entity]; |
|
117 | - if ($object->type == Product::TYPE_SERVICE) $dir=$conf->service->multidir_output[$object->entity]; |
|
130 | + if ($object->type == Product::TYPE_PRODUCT) { |
|
131 | + $dir=$conf->product->multidir_output[$object->entity]; |
|
132 | + } |
|
133 | + if ($object->type == Product::TYPE_SERVICE) { |
|
134 | + $dir=$conf->service->multidir_output[$object->entity]; |
|
135 | + } |
|
118 | 136 | } |
119 | -} |
|
120 | -elseif ($modulepart == 'project') |
|
137 | +} elseif ($modulepart == 'project') |
|
121 | 138 | { |
122 | 139 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
123 | 140 | $object = new Project($db); |
124 | 141 | if ($id > 0) |
125 | 142 | { |
126 | 143 | $result = $object->fetch($id); |
127 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
144 | + if ($result <= 0) { |
|
145 | + dol_print_error($db,'Failed to load object'); |
|
146 | + } |
|
128 | 147 | $dir=$conf->projet->dir_output; // By default |
129 | 148 | } |
130 | -} |
|
131 | -elseif ($modulepart == 'holiday') |
|
149 | +} elseif ($modulepart == 'holiday') |
|
132 | 150 | { |
133 | 151 | require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; |
134 | 152 | $object = new Holiday($db); |
135 | 153 | if ($id > 0) |
136 | 154 | { |
137 | 155 | $result = $object->fetch($id); |
138 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
156 | + if ($result <= 0) { |
|
157 | + dol_print_error($db,'Failed to load object'); |
|
158 | + } |
|
139 | 159 | $dir=$conf->holiday->dir_output; // By default |
140 | 160 | } |
141 | -} |
|
142 | -elseif ($modulepart == 'member') |
|
161 | +} elseif ($modulepart == 'member') |
|
143 | 162 | { |
144 | 163 | require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
145 | 164 | $object = new Adherent($db); |
146 | 165 | if ($id > 0) |
147 | 166 | { |
148 | 167 | $result = $object->fetch($id); |
149 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
168 | + if ($result <= 0) { |
|
169 | + dol_print_error($db,'Failed to load object'); |
|
170 | + } |
|
150 | 171 | $dir=$conf->adherent->dir_output; // By default |
151 | 172 | } |
152 | -} |
|
153 | -elseif ($modulepart == 'societe') |
|
173 | +} elseif ($modulepart == 'societe') |
|
154 | 174 | { |
155 | 175 | require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; |
156 | 176 | $object = new Societe($db); |
157 | 177 | if ($id > 0) |
158 | 178 | { |
159 | 179 | $result = $object->fetch($id); |
160 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
180 | + if ($result <= 0) { |
|
181 | + dol_print_error($db,'Failed to load object'); |
|
182 | + } |
|
161 | 183 | $dir=$conf->societe->dir_output; |
162 | 184 | } |
163 | -} |
|
164 | -elseif ($modulepart == 'user') |
|
185 | +} elseif ($modulepart == 'user') |
|
165 | 186 | { |
166 | 187 | require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; |
167 | 188 | $object = new User($db); |
168 | 189 | if ($id > 0) |
169 | 190 | { |
170 | 191 | $result = $object->fetch($id); |
171 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
192 | + if ($result <= 0) { |
|
193 | + dol_print_error($db,'Failed to load object'); |
|
194 | + } |
|
172 | 195 | $dir=$conf->user->dir_output; // By default |
173 | 196 | } |
174 | -} |
|
175 | -elseif ($modulepart == 'expensereport') |
|
197 | +} elseif ($modulepart == 'expensereport') |
|
176 | 198 | { |
177 | 199 | require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; |
178 | 200 | $object = new ExpenseReport($db); |
179 | 201 | if ($id > 0) |
180 | 202 | { |
181 | 203 | $result = $object->fetch($id); |
182 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
204 | + if ($result <= 0) { |
|
205 | + dol_print_error($db,'Failed to load object'); |
|
206 | + } |
|
183 | 207 | $dir=$conf->expensereport->dir_output; // By default |
184 | 208 | } |
185 | -} |
|
186 | -elseif ($modulepart == 'tax') |
|
209 | +} elseif ($modulepart == 'tax') |
|
187 | 210 | { |
188 | 211 | require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; |
189 | 212 | $object = new ChargeSociales($db); |
190 | 213 | if ($id > 0) |
191 | 214 | { |
192 | 215 | $result = $object->fetch($id); |
193 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
216 | + if ($result <= 0) { |
|
217 | + dol_print_error($db,'Failed to load object'); |
|
218 | + } |
|
194 | 219 | $dir=$conf->tax->dir_output; // By default |
195 | 220 | } |
196 | -} |
|
197 | -elseif ($modulepart == 'ticket') |
|
221 | +} elseif ($modulepart == 'ticket') |
|
198 | 222 | { |
199 | 223 | require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; |
200 | 224 | $object = new Ticket($db); |
201 | 225 | if ($id > 0) |
202 | 226 | { |
203 | 227 | $result = $object->fetch($id); |
204 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
228 | + if ($result <= 0) { |
|
229 | + dol_print_error($db,'Failed to load object'); |
|
230 | + } |
|
205 | 231 | $dir=$conf->ticket->dir_output; // By default |
206 | 232 | } |
207 | -} |
|
208 | -else { |
|
233 | +} else { |
|
209 | 234 | print 'Action crop for module part '.$modulepart.' is not supported yet.'; |
210 | 235 | } |
211 | 236 | |
212 | 237 | if (empty($backtourl)) |
213 | 238 | { |
214 | - if (in_array($modulepart, array('product','produit','service','produit|service'))) $backtourl=DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
215 | - else if (in_array($modulepart, array('expensereport'))) $backtourl=DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
216 | - else if (in_array($modulepart, array('holiday'))) $backtourl=DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
217 | - else if (in_array($modulepart, array('member'))) $backtourl=DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
218 | - else if (in_array($modulepart, array('project'))) $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
219 | - else if (in_array($modulepart, array('societe'))) $backtourl=DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
220 | - else if (in_array($modulepart, array('tax'))) $backtourl=DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
221 | - else if (in_array($modulepart, array('ticket'))) $backtourl=DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
222 | - else if (in_array($modulepart, array('user'))) $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
223 | -} |
|
239 | + if (in_array($modulepart, array('product','produit','service','produit|service'))) { |
|
240 | + $backtourl=DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
241 | + } else if (in_array($modulepart, array('expensereport'))) { |
|
242 | + $backtourl=DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
243 | + } else if (in_array($modulepart, array('holiday'))) { |
|
244 | + $backtourl=DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
245 | + } else if (in_array($modulepart, array('member'))) { |
|
246 | + $backtourl=DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
247 | + } else if (in_array($modulepart, array('project'))) { |
|
248 | + $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
249 | + } else if (in_array($modulepart, array('societe'))) { |
|
250 | + $backtourl=DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
251 | + } else if (in_array($modulepart, array('tax'))) { |
|
252 | + $backtourl=DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
253 | + } else if (in_array($modulepart, array('ticket'))) { |
|
254 | + $backtourl=DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
255 | + } else if (in_array($modulepart, array('user'))) { |
|
256 | + $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
257 | + } |
|
258 | + } |
|
224 | 259 | |
225 | 260 | |
226 | 261 | /* |
@@ -233,8 +268,7 @@ discard block |
||
233 | 268 | { |
234 | 269 | header("Location: ".$backtourl); |
235 | 270 | exit; |
236 | - } |
|
237 | - else |
|
271 | + } else |
|
238 | 272 | { |
239 | 273 | dol_print_error('', 'Cancel on photo_resize with a not supported value of modulepart='.$modulepart); |
240 | 274 | exit; |
@@ -258,19 +292,22 @@ discard block |
||
258 | 292 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
259 | 293 | $ecmfile=new EcmFiles($db); |
260 | 294 | $result = $ecmfile->fetch(0, '', $rel_filename); |
261 | - if ($result > 0) // If found |
|
295 | + if ($result > 0) { |
|
296 | + // If found |
|
262 | 297 | { |
263 | 298 | $filename = basename($rel_filename); |
299 | + } |
|
264 | 300 | $rel_dir = dirname($rel_filename); |
265 | 301 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
266 | 302 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
267 | 303 | |
268 | 304 | $ecmfile->label = md5_file(dol_osencode($fullpath)); |
269 | 305 | $result = $ecmfile->update($user); |
270 | - } |
|
271 | - elseif ($result == 0) // If not found |
|
306 | + } elseif ($result == 0) { |
|
307 | + // If not found |
|
272 | 308 | { |
273 | 309 | $filename = basename($rel_filename); |
310 | + } |
|
274 | 311 | $rel_dir = dirname($rel_filename); |
275 | 312 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
276 | 313 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
@@ -294,14 +331,12 @@ discard block |
||
294 | 331 | { |
295 | 332 | header("Location: ".$backtourl); |
296 | 333 | exit; |
297 | - } |
|
298 | - else |
|
334 | + } else |
|
299 | 335 | { |
300 | 336 | dol_print_error('', 'confirm_resize on photo_resize without backtourl defined for modulepart='.$modulepart); |
301 | 337 | exit; |
302 | 338 | } |
303 | - } |
|
304 | - else |
|
339 | + } else |
|
305 | 340 | { |
306 | 341 | setEventMessages($result, null, 'errors'); |
307 | 342 | $_GET['file']=$_POST["file"]; |
@@ -328,19 +363,22 @@ discard block |
||
328 | 363 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
329 | 364 | $ecmfile=new EcmFiles($db); |
330 | 365 | $result = $ecmfile->fetch(0, '', $rel_filename); |
331 | - if ($result > 0) // If found |
|
366 | + if ($result > 0) { |
|
367 | + // If found |
|
332 | 368 | { |
333 | 369 | $filename = basename($rel_filename); |
370 | + } |
|
334 | 371 | $rel_dir = dirname($rel_filename); |
335 | 372 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
336 | 373 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
337 | 374 | |
338 | 375 | $ecmfile->label = md5_file(dol_osencode($fullpath)); |
339 | 376 | $result = $ecmfile->update($user); |
340 | - } |
|
341 | - elseif ($result == 0) // If not found |
|
377 | + } elseif ($result == 0) { |
|
378 | + // If not found |
|
342 | 379 | { |
343 | 380 | $filename = basename($rel_filename); |
381 | + } |
|
344 | 382 | $rel_dir = dirname($rel_filename); |
345 | 383 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
346 | 384 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
@@ -364,14 +402,12 @@ discard block |
||
364 | 402 | { |
365 | 403 | header("Location: ".$backtourl); |
366 | 404 | exit; |
367 | - } |
|
368 | - else |
|
405 | + } else |
|
369 | 406 | { |
370 | 407 | dol_print_error('', 'confirm_crop on photo_resize without backtourl defined for modulepart='.$modulepart); |
371 | 408 | exit; |
372 | 409 | } |
373 | - } |
|
374 | - else |
|
410 | + } else |
|
375 | 411 | { |
376 | 412 | setEventMessages($result, null, 'errors'); |
377 | 413 | $_GET['file']=$_POST["file"]; |
@@ -26,81 +26,81 @@ discard block |
||
26 | 26 | |
27 | 27 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
28 | 28 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
29 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
30 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php'; |
|
29 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
30 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; |
|
31 | 31 | require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
32 | 32 | |
33 | 33 | // Load translation files required by the page |
34 | -$langs->loadLangs(array("products","other")); |
|
34 | +$langs->loadLangs(array("products", "other")); |
|
35 | 35 | |
36 | -$id=GETPOST('id','int'); |
|
37 | -$action=GETPOST('action','alpha'); |
|
38 | -$modulepart=GETPOST('modulepart','alpha')?GETPOST('modulepart','alpha'):'produit|service'; |
|
36 | +$id = GETPOST('id', 'int'); |
|
37 | +$action = GETPOST('action', 'alpha'); |
|
38 | +$modulepart = GETPOST('modulepart', 'alpha') ?GETPOST('modulepart', 'alpha') : 'produit|service'; |
|
39 | 39 | $original_file = GETPOST("file"); |
40 | -$backtourl=GETPOST('backtourl'); |
|
41 | -$cancel=GETPOST('cancel','alpha'); |
|
40 | +$backtourl = GETPOST('backtourl'); |
|
41 | +$cancel = GETPOST('cancel', 'alpha'); |
|
42 | 42 | |
43 | 43 | // Security check |
44 | 44 | if (empty($modulepart)) accessforbidden('Bad value for modulepart'); |
45 | -$accessallowed=0; |
|
45 | +$accessallowed = 0; |
|
46 | 46 | if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service') |
47 | 47 | { |
48 | - $result=restrictedArea($user,'produit|service',$id,'product&product'); |
|
49 | - if ($modulepart=='produit|service' && (! $user->rights->produit->lire && ! $user->rights->service->lire)) accessforbidden(); |
|
50 | - $accessallowed=1; |
|
48 | + $result = restrictedArea($user, 'produit|service', $id, 'product&product'); |
|
49 | + if ($modulepart == 'produit|service' && (!$user->rights->produit->lire && !$user->rights->service->lire)) accessforbidden(); |
|
50 | + $accessallowed = 1; |
|
51 | 51 | } |
52 | 52 | elseif ($modulepart == 'project') |
53 | 53 | { |
54 | - $result=restrictedArea($user,'projet',$id); |
|
55 | - if (! $user->rights->projet->lire) accessforbidden(); |
|
56 | - $accessallowed=1; |
|
54 | + $result = restrictedArea($user, 'projet', $id); |
|
55 | + if (!$user->rights->projet->lire) accessforbidden(); |
|
56 | + $accessallowed = 1; |
|
57 | 57 | } |
58 | 58 | elseif ($modulepart == 'expensereport') |
59 | 59 | { |
60 | - $result=restrictedArea($user,'expensereport',$id,'expensereport'); |
|
61 | - if (! $user->rights->expensereport->lire) accessforbidden(); |
|
62 | - $accessallowed=1; |
|
60 | + $result = restrictedArea($user, 'expensereport', $id, 'expensereport'); |
|
61 | + if (!$user->rights->expensereport->lire) accessforbidden(); |
|
62 | + $accessallowed = 1; |
|
63 | 63 | } |
64 | 64 | elseif ($modulepart == 'holiday') |
65 | 65 | { |
66 | - $result=restrictedArea($user,'holiday',$id,'holiday'); |
|
67 | - if (! $user->rights->holiday->read) accessforbidden(); |
|
68 | - $accessallowed=1; |
|
66 | + $result = restrictedArea($user, 'holiday', $id, 'holiday'); |
|
67 | + if (!$user->rights->holiday->read) accessforbidden(); |
|
68 | + $accessallowed = 1; |
|
69 | 69 | } |
70 | 70 | elseif ($modulepart == 'member') |
71 | 71 | { |
72 | - $result=restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid'); |
|
73 | - if (! $user->rights->adherent->lire) accessforbidden(); |
|
74 | - $accessallowed=1; |
|
72 | + $result = restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid'); |
|
73 | + if (!$user->rights->adherent->lire) accessforbidden(); |
|
74 | + $accessallowed = 1; |
|
75 | 75 | } |
76 | 76 | elseif ($modulepart == 'user') |
77 | 77 | { |
78 | - $result=restrictedArea($user,'user',$id,'user'); |
|
79 | - if (! $user->rights->user->user->lire) accessforbidden(); |
|
80 | - $accessallowed=1; |
|
78 | + $result = restrictedArea($user, 'user', $id, 'user'); |
|
79 | + if (!$user->rights->user->user->lire) accessforbidden(); |
|
80 | + $accessallowed = 1; |
|
81 | 81 | } |
82 | 82 | elseif ($modulepart == 'societe') |
83 | 83 | { |
84 | - $result=restrictedArea($user,'societe',$id,'societe'); |
|
85 | - if (! $user->rights->societe->lire) accessforbidden(); |
|
86 | - $accessallowed=1; |
|
84 | + $result = restrictedArea($user, 'societe', $id, 'societe'); |
|
85 | + if (!$user->rights->societe->lire) accessforbidden(); |
|
86 | + $accessallowed = 1; |
|
87 | 87 | } |
88 | 88 | elseif ($modulepart == 'tax') |
89 | 89 | { |
90 | - $result=restrictedArea($user, 'tax', $id, 'chargesociales','charges'); |
|
91 | - if (! $user->rights->tax->charges->lire) accessforbidden(); |
|
92 | - $accessallowed=1; |
|
90 | + $result = restrictedArea($user, 'tax', $id, 'chargesociales', 'charges'); |
|
91 | + if (!$user->rights->tax->charges->lire) accessforbidden(); |
|
92 | + $accessallowed = 1; |
|
93 | 93 | } |
94 | 94 | elseif ($modulepart == 'ticket') |
95 | 95 | { |
96 | - $result=restrictedArea($user,'ticket',$id,'ticket'); |
|
97 | - if (! $user->rights->ticket->read) accessforbidden(); |
|
98 | - $accessallowed=1; |
|
96 | + $result = restrictedArea($user, 'ticket', $id, 'ticket'); |
|
97 | + if (!$user->rights->ticket->read) accessforbidden(); |
|
98 | + $accessallowed = 1; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | // Security: |
102 | 102 | // Limit access if permissions are wrong |
103 | -if (! $accessallowed) |
|
103 | +if (!$accessallowed) |
|
104 | 104 | { |
105 | 105 | accessforbidden(); |
106 | 106 | } |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | if ($id > 0) |
114 | 114 | { |
115 | 115 | $result = $object->fetch($id); |
116 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
117 | - $dir=$conf->product->multidir_output[$object->entity]; // By default |
|
118 | - if ($object->type == Product::TYPE_PRODUCT) $dir=$conf->product->multidir_output[$object->entity]; |
|
119 | - if ($object->type == Product::TYPE_SERVICE) $dir=$conf->service->multidir_output[$object->entity]; |
|
116 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
117 | + $dir = $conf->product->multidir_output[$object->entity]; // By default |
|
118 | + if ($object->type == Product::TYPE_PRODUCT) $dir = $conf->product->multidir_output[$object->entity]; |
|
119 | + if ($object->type == Product::TYPE_SERVICE) $dir = $conf->service->multidir_output[$object->entity]; |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | elseif ($modulepart == 'project') |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | if ($id > 0) |
127 | 127 | { |
128 | 128 | $result = $object->fetch($id); |
129 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
130 | - $dir=$conf->projet->dir_output; // By default |
|
129 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
130 | + $dir = $conf->projet->dir_output; // By default |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | elseif ($modulepart == 'holiday') |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | if ($id > 0) |
138 | 138 | { |
139 | 139 | $result = $object->fetch($id); |
140 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
141 | - $dir=$conf->holiday->dir_output; // By default |
|
140 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
141 | + $dir = $conf->holiday->dir_output; // By default |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | elseif ($modulepart == 'member') |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | if ($id > 0) |
149 | 149 | { |
150 | 150 | $result = $object->fetch($id); |
151 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
152 | - $dir=$conf->adherent->dir_output; // By default |
|
151 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
152 | + $dir = $conf->adherent->dir_output; // By default |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | elseif ($modulepart == 'societe') |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | if ($id > 0) |
160 | 160 | { |
161 | 161 | $result = $object->fetch($id); |
162 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
163 | - $dir=$conf->societe->dir_output; |
|
162 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
163 | + $dir = $conf->societe->dir_output; |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | elseif ($modulepart == 'user') |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | if ($id > 0) |
171 | 171 | { |
172 | 172 | $result = $object->fetch($id); |
173 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
174 | - $dir=$conf->user->dir_output; // By default |
|
173 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
174 | + $dir = $conf->user->dir_output; // By default |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | elseif ($modulepart == 'expensereport') |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | if ($id > 0) |
182 | 182 | { |
183 | 183 | $result = $object->fetch($id); |
184 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
185 | - $dir=$conf->expensereport->dir_output; // By default |
|
184 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
185 | + $dir = $conf->expensereport->dir_output; // By default |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | elseif ($modulepart == 'tax') |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | if ($id > 0) |
193 | 193 | { |
194 | 194 | $result = $object->fetch($id); |
195 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
196 | - $dir=$conf->tax->dir_output; // By default |
|
195 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
196 | + $dir = $conf->tax->dir_output; // By default |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | elseif ($modulepart == 'ticket') |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | if ($id > 0) |
204 | 204 | { |
205 | 205 | $result = $object->fetch($id); |
206 | - if ($result <= 0) dol_print_error($db,'Failed to load object'); |
|
207 | - $dir=$conf->ticket->dir_output; // By default |
|
206 | + if ($result <= 0) dol_print_error($db, 'Failed to load object'); |
|
207 | + $dir = $conf->ticket->dir_output; // By default |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | else { |
@@ -213,15 +213,15 @@ discard block |
||
213 | 213 | |
214 | 214 | if (empty($backtourl)) |
215 | 215 | { |
216 | - if (in_array($modulepart, array('product','produit','service','produit|service'))) $backtourl=DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
217 | - else if (in_array($modulepart, array('expensereport'))) $backtourl=DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
218 | - else if (in_array($modulepart, array('holiday'))) $backtourl=DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
219 | - else if (in_array($modulepart, array('member'))) $backtourl=DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
220 | - else if (in_array($modulepart, array('project'))) $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
221 | - else if (in_array($modulepart, array('societe'))) $backtourl=DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
222 | - else if (in_array($modulepart, array('tax'))) $backtourl=DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
223 | - else if (in_array($modulepart, array('ticket'))) $backtourl=DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
224 | - else if (in_array($modulepart, array('user'))) $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
216 | + if (in_array($modulepart, array('product', 'produit', 'service', 'produit|service'))) $backtourl = DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
217 | + else if (in_array($modulepart, array('expensereport'))) $backtourl = DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
218 | + else if (in_array($modulepart, array('holiday'))) $backtourl = DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
219 | + else if (in_array($modulepart, array('member'))) $backtourl = DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
220 | + else if (in_array($modulepart, array('project'))) $backtourl = DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
221 | + else if (in_array($modulepart, array('societe'))) $backtourl = DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
222 | + else if (in_array($modulepart, array('tax'))) $backtourl = DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
223 | + else if (in_array($modulepart, array('ticket'))) $backtourl = DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
224 | + else if (in_array($modulepart, array('user'))) $backtourl = DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -245,20 +245,20 @@ discard block |
||
245 | 245 | |
246 | 246 | if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POST["sizex"]) != "") && (isset($_POST["sizey"]) != "")) |
247 | 247 | { |
248 | - $fullpath=$dir."/".$original_file; |
|
248 | + $fullpath = $dir."/".$original_file; |
|
249 | 249 | |
250 | - $result=dol_imageResizeOrCrop($fullpath,0,$_POST['sizex'],$_POST['sizey']); |
|
250 | + $result = dol_imageResizeOrCrop($fullpath, 0, $_POST['sizex'], $_POST['sizey']); |
|
251 | 251 | |
252 | 252 | if ($result == $fullpath) |
253 | 253 | { |
254 | 254 | $object->addThumbs($fullpath); |
255 | 255 | |
256 | 256 | // Update/create database for file $fullpath |
257 | - $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath); |
|
258 | - $rel_filename = preg_replace('/^[\\/]/','',$rel_filename); |
|
257 | + $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $fullpath); |
|
258 | + $rel_filename = preg_replace('/^[\\/]/', '', $rel_filename); |
|
259 | 259 | |
260 | 260 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
261 | - $ecmfile=new EcmFiles($db); |
|
261 | + $ecmfile = new EcmFiles($db); |
|
262 | 262 | $result = $ecmfile->fetch(0, '', $rel_filename); |
263 | 263 | if ($result > 0) // If found |
264 | 264 | { |
@@ -279,11 +279,11 @@ discard block |
||
279 | 279 | |
280 | 280 | $ecmfile->filepath = $rel_dir; |
281 | 281 | $ecmfile->filename = $filename; |
282 | - $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file |
|
282 | + $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file |
|
283 | 283 | $ecmfile->fullpath_orig = $fullpath; |
284 | 284 | $ecmfile->gen_or_uploaded = 'unknown'; |
285 | - $ecmfile->description = ''; // indexed content |
|
286 | - $ecmfile->keyword = ''; // keyword content |
|
285 | + $ecmfile->description = ''; // indexed content |
|
286 | + $ecmfile->keyword = ''; // keyword content |
|
287 | 287 | $result = $ecmfile->create($user); |
288 | 288 | if ($result < 0) |
289 | 289 | { |
@@ -306,29 +306,29 @@ discard block |
||
306 | 306 | else |
307 | 307 | { |
308 | 308 | setEventMessages($result, null, 'errors'); |
309 | - $_GET['file']=$_POST["file"]; |
|
310 | - $action=''; |
|
309 | + $_GET['file'] = $_POST["file"]; |
|
310 | + $action = ''; |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | 314 | // Crop d'une image |
315 | 315 | if ($action == 'confirm_crop') |
316 | 316 | { |
317 | - $fullpath=$dir."/".$original_file; |
|
317 | + $fullpath = $dir."/".$original_file; |
|
318 | 318 | |
319 | 319 | //var_dump($_POST['w'].'x'.$_POST['h'].'-'.$_POST['x'].'x'.$_POST['y']);exit; |
320 | - $result=dol_imageResizeOrCrop($fullpath,1,$_POST['w'],$_POST['h'],$_POST['x'],$_POST['y']); |
|
320 | + $result = dol_imageResizeOrCrop($fullpath, 1, $_POST['w'], $_POST['h'], $_POST['x'], $_POST['y']); |
|
321 | 321 | |
322 | 322 | if ($result == $fullpath) |
323 | 323 | { |
324 | 324 | $object->addThumbs($fullpath); |
325 | 325 | |
326 | 326 | // Update/create database for file $fullpath |
327 | - $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath); |
|
328 | - $rel_filename = preg_replace('/^[\\/]/','',$rel_filename); |
|
327 | + $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $fullpath); |
|
328 | + $rel_filename = preg_replace('/^[\\/]/', '', $rel_filename); |
|
329 | 329 | |
330 | 330 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
331 | - $ecmfile=new EcmFiles($db); |
|
331 | + $ecmfile = new EcmFiles($db); |
|
332 | 332 | $result = $ecmfile->fetch(0, '', $rel_filename); |
333 | 333 | if ($result > 0) // If found |
334 | 334 | { |
@@ -349,11 +349,11 @@ discard block |
||
349 | 349 | |
350 | 350 | $ecmfile->filepath = $rel_dir; |
351 | 351 | $ecmfile->filename = $filename; |
352 | - $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file |
|
352 | + $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file |
|
353 | 353 | $ecmfile->fullpath_orig = $fullpath; |
354 | 354 | $ecmfile->gen_or_uploaded = 'unknown'; |
355 | - $ecmfile->description = ''; // indexed content |
|
356 | - $ecmfile->keyword = ''; // keyword content |
|
355 | + $ecmfile->description = ''; // indexed content |
|
356 | + $ecmfile->keyword = ''; // keyword content |
|
357 | 357 | $result = $ecmfile->create($user); |
358 | 358 | if ($result < 0) |
359 | 359 | { |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | else |
377 | 377 | { |
378 | 378 | setEventMessages($result, null, 'errors'); |
379 | - $_GET['file']=$_POST["file"]; |
|
380 | - $action=''; |
|
379 | + $_GET['file'] = $_POST["file"]; |
|
380 | + $action = ''; |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
@@ -386,14 +386,14 @@ discard block |
||
386 | 386 | * View |
387 | 387 | */ |
388 | 388 | |
389 | -llxHeader($head, $langs->trans("Image"), '', '', 0, 0, array('/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js','/core/js/lib_photosresize.js'), array('/includes/jquery/plugins/jcrop/css/jquery.Jcrop.css')); |
|
389 | +llxHeader($head, $langs->trans("Image"), '', '', 0, 0, array('/includes/jquery/plugins/jcrop/js/jquery.Jcrop.min.js', '/core/js/lib_photosresize.js'), array('/includes/jquery/plugins/jcrop/css/jquery.Jcrop.css')); |
|
390 | 390 | |
391 | 391 | |
392 | 392 | print load_fiche_titre($langs->trans("ImageEditor")); |
393 | 393 | |
394 | -$infoarray=dol_getImageSize($dir."/".GETPOST("file",'alpha')); |
|
395 | -$height=$infoarray['height']; |
|
396 | -$width=$infoarray['width']; |
|
394 | +$infoarray = dol_getImageSize($dir."/".GETPOST("file", 'alpha')); |
|
395 | +$height = $infoarray['height']; |
|
396 | +$width = $infoarray['width']; |
|
397 | 397 | print $langs->trans("CurrentInformationOnImage").': '; |
398 | 398 | print $langs->trans("Width").': <strong>'.$width.'</strong> x '.$langs->trans("Height").': <strong>'.$height.'</strong><br>'; |
399 | 399 | |
@@ -433,18 +433,18 @@ discard block |
||
433 | 433 | |
434 | 434 | print '<br>'."\n"; |
435 | 435 | |
436 | -if (! empty($conf->use_javascript_ajax)) |
|
436 | +if (!empty($conf->use_javascript_ajax)) |
|
437 | 437 | { |
438 | - $infoarray=dol_getImageSize($dir."/".GETPOST("file")); |
|
439 | - $height=$infoarray['height']; |
|
440 | - $width=$infoarray['width']; |
|
441 | - $widthforcrop=$width; $refsizeforcrop='orig'; $ratioforcrop=1; |
|
438 | + $infoarray = dol_getImageSize($dir."/".GETPOST("file")); |
|
439 | + $height = $infoarray['height']; |
|
440 | + $width = $infoarray['width']; |
|
441 | + $widthforcrop = $width; $refsizeforcrop = 'orig'; $ratioforcrop = 1; |
|
442 | 442 | // If image is too large, we use another scale. |
443 | - if (! empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth']/2))) |
|
443 | + if (!empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth'] / 2))) |
|
444 | 444 | { |
445 | - $ratioforcrop=2; |
|
446 | - $widthforcrop=round($_SESSION['dol_screenwidth'] / $ratioforcrop); |
|
447 | - $refsizeforcrop='screenwidth'; |
|
445 | + $ratioforcrop = 2; |
|
446 | + $widthforcrop = round($_SESSION['dol_screenwidth'] / $ratioforcrop); |
|
447 | + $refsizeforcrop = 'screenwidth'; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | print '<!-- Form to crop -->'."\n"; |
@@ -33,107 +33,107 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class box_factures_imp extends ModeleBoxes |
35 | 35 | { |
36 | - var $boxcode="oldestunpaidcustomerbills"; |
|
37 | - var $boximg="object_bill"; |
|
38 | - var $boxlabel="BoxOldestUnpaidCustomerBills"; |
|
39 | - var $depends = array("facture"); |
|
36 | + var $boxcode="oldestunpaidcustomerbills"; |
|
37 | + var $boximg="object_bill"; |
|
38 | + var $boxlabel="BoxOldestUnpaidCustomerBills"; |
|
39 | + var $depends = array("facture"); |
|
40 | 40 | |
41 | - /** |
|
41 | + /** |
|
42 | 42 | * @var DoliDB Database handler. |
43 | 43 | */ |
44 | 44 | public $db; |
45 | 45 | |
46 | - var $param; |
|
46 | + var $param; |
|
47 | 47 | |
48 | - var $info_box_head = array(); |
|
49 | - var $info_box_contents = array(); |
|
48 | + var $info_box_head = array(); |
|
49 | + var $info_box_contents = array(); |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * Constructor |
|
54 | - * |
|
55 | - * @param DoliDB $db Database handler |
|
56 | - * @param string $param More parameters |
|
57 | - */ |
|
58 | - function __construct($db,$param) |
|
59 | - { |
|
60 | - global $user; |
|
52 | + /** |
|
53 | + * Constructor |
|
54 | + * |
|
55 | + * @param DoliDB $db Database handler |
|
56 | + * @param string $param More parameters |
|
57 | + */ |
|
58 | + function __construct($db,$param) |
|
59 | + { |
|
60 | + global $user; |
|
61 | 61 | |
62 | - $this->db=$db; |
|
62 | + $this->db=$db; |
|
63 | 63 | |
64 | - $this->hidden=! ($user->rights->facture->lire); |
|
65 | - } |
|
64 | + $this->hidden=! ($user->rights->facture->lire); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Load data into info_box_contents array to show array later. |
|
69 | - * |
|
70 | - * @param int $max Maximum number of records to load |
|
67 | + /** |
|
68 | + * Load data into info_box_contents array to show array later. |
|
69 | + * |
|
70 | + * @param int $max Maximum number of records to load |
|
71 | 71 | * @return void |
72 | - */ |
|
73 | - function loadBox($max=5) |
|
74 | - { |
|
75 | - global $conf, $user, $langs, $db; |
|
72 | + */ |
|
73 | + function loadBox($max=5) |
|
74 | + { |
|
75 | + global $conf, $user, $langs, $db; |
|
76 | 76 | |
77 | - $this->max=$max; |
|
77 | + $this->max=$max; |
|
78 | 78 | |
79 | - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
79 | + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
80 | 80 | include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
81 | 81 | |
82 | 82 | $facturestatic = new Facture($db); |
83 | 83 | $societestatic = new Societe($db); |
84 | 84 | |
85 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidCustomerBills",$max)); |
|
85 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidCustomerBills",$max)); |
|
86 | 86 | |
87 | - if ($user->rights->facture->lire) |
|
88 | - { |
|
89 | - $sql = "SELECT s.nom as name, s.rowid as socid, s.email,"; |
|
87 | + if ($user->rights->facture->lire) |
|
88 | + { |
|
89 | + $sql = "SELECT s.nom as name, s.rowid as socid, s.email,"; |
|
90 | 90 | $sql.= " s.code_client,"; |
91 | 91 | $sql.= " s.logo,"; |
92 | - $sql.= " f.ref, f.date_lim_reglement as datelimite,"; |
|
92 | + $sql.= " f.ref, f.date_lim_reglement as datelimite,"; |
|
93 | 93 | $sql.= " f.type,"; |
94 | - $sql.= " f.amount, f.datef as df,"; |
|
94 | + $sql.= " f.amount, f.datef as df,"; |
|
95 | 95 | $sql.= " f.total as total_ht,"; |
96 | 96 | $sql.= " f.tva as total_tva,"; |
97 | 97 | $sql.= " f.total_ttc,"; |
98 | - $sql.= " f.paye, f.fk_statut, f.rowid as facid"; |
|
99 | - $sql.= ", sum(pf.amount) as am"; |
|
100 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
101 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
102 | - $sql.= ", ".MAIN_DB_PREFIX."facture as f"; |
|
103 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; |
|
104 | - $sql.= " WHERE f.fk_soc = s.rowid"; |
|
105 | - $sql.= " AND f.entity = ".$conf->entity; |
|
106 | - $sql.= " AND f.paye = 0"; |
|
107 | - $sql.= " AND fk_statut = 1"; |
|
108 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
109 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
110 | - $sql.= " GROUP BY s.nom, s.rowid, s.code_client, s.logo, f.ref, f.date_lim_reglement,"; |
|
111 | - $sql.= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; |
|
112 | - //$sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
|
113 | - $sql.= " ORDER BY datelimite ASC, f.ref ASC "; |
|
114 | - $sql.= $db->plimit($max, 0); |
|
115 | - |
|
116 | - $result = $db->query($sql); |
|
117 | - if ($result) |
|
118 | - { |
|
119 | - $num = $db->num_rows($result); |
|
120 | - $now=dol_now(); |
|
121 | - |
|
122 | - $line = 0; |
|
123 | - $l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateDue')).': %s)'; |
|
124 | - |
|
125 | - while ($line < $num) |
|
126 | - { |
|
127 | - $objp = $db->fetch_object($result); |
|
128 | - $datelimite=$db->jdate($objp->datelimite); |
|
98 | + $sql.= " f.paye, f.fk_statut, f.rowid as facid"; |
|
99 | + $sql.= ", sum(pf.amount) as am"; |
|
100 | + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
101 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
102 | + $sql.= ", ".MAIN_DB_PREFIX."facture as f"; |
|
103 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; |
|
104 | + $sql.= " WHERE f.fk_soc = s.rowid"; |
|
105 | + $sql.= " AND f.entity = ".$conf->entity; |
|
106 | + $sql.= " AND f.paye = 0"; |
|
107 | + $sql.= " AND fk_statut = 1"; |
|
108 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
109 | + if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
110 | + $sql.= " GROUP BY s.nom, s.rowid, s.code_client, s.logo, f.ref, f.date_lim_reglement,"; |
|
111 | + $sql.= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; |
|
112 | + //$sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
|
113 | + $sql.= " ORDER BY datelimite ASC, f.ref ASC "; |
|
114 | + $sql.= $db->plimit($max, 0); |
|
115 | + |
|
116 | + $result = $db->query($sql); |
|
117 | + if ($result) |
|
118 | + { |
|
119 | + $num = $db->num_rows($result); |
|
120 | + $now=dol_now(); |
|
121 | + |
|
122 | + $line = 0; |
|
123 | + $l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateDue')).': %s)'; |
|
124 | + |
|
125 | + while ($line < $num) |
|
126 | + { |
|
127 | + $objp = $db->fetch_object($result); |
|
128 | + $datelimite=$db->jdate($objp->datelimite); |
|
129 | 129 | $facturestatic->id = $objp->facid; |
130 | 130 | $facturestatic->ref = $objp->ref; |
131 | 131 | $facturestatic->type = $objp->type; |
132 | 132 | $facturestatic->total_ht = $objp->total_ht; |
133 | 133 | $facturestatic->total_tva = $objp->total_tva; |
134 | 134 | $facturestatic->total_ttc = $objp->total_ttc; |
135 | - $facturestatic->statut = $objp->fk_statut; |
|
136 | - $facturestatic->date_lim_reglement = $db->jdate($objp->datelimite); |
|
135 | + $facturestatic->statut = $objp->fk_statut; |
|
136 | + $facturestatic->date_lim_reglement = $db->jdate($objp->datelimite); |
|
137 | 137 | |
138 | 138 | $societestatic->id = $objp->socid; |
139 | 139 | $societestatic->name = $objp->name; |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | $societestatic->code_client = $objp->code_client; |
143 | 143 | $societestatic->logo = $objp->logo; |
144 | 144 | |
145 | - $late=''; |
|
146 | - if ($facturestatic->hasDelay()) { |
|
147 | - $late = img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day'))); |
|
148 | - } |
|
145 | + $late=''; |
|
146 | + if ($facturestatic->hasDelay()) { |
|
147 | + $late = img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day'))); |
|
148 | + } |
|
149 | 149 | |
150 | 150 | $this->info_box_contents[$line][] = array( |
151 | 151 | 'td' => '', |
@@ -175,40 +175,40 @@ discard block |
||
175 | 175 | 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$objp->am), |
176 | 176 | ); |
177 | 177 | |
178 | - $line++; |
|
179 | - } |
|
178 | + $line++; |
|
179 | + } |
|
180 | 180 | |
181 | - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoUnpaidCustomerBills")); |
|
181 | + if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoUnpaidCustomerBills")); |
|
182 | 182 | |
183 | - $db->free($result); |
|
184 | - } |
|
185 | - else |
|
186 | - { |
|
183 | + $db->free($result); |
|
184 | + } |
|
185 | + else |
|
186 | + { |
|
187 | 187 | $this->info_box_contents[0][0] = array( |
188 | 188 | 'td' => '', |
189 | 189 | 'maxlength'=>500, |
190 | 190 | 'text' => ($db->error().' sql='.$sql), |
191 | 191 | ); |
192 | - } |
|
193 | - } |
|
194 | - else { |
|
192 | + } |
|
193 | + } |
|
194 | + else { |
|
195 | 195 | $this->info_box_contents[0][0] = array( |
196 | 196 | 'td' => 'align="left" class="nohover opacitymedium"', |
197 | 197 | 'text' => $langs->trans("ReadPermissionNotAllowed") |
198 | 198 | ); |
199 | - } |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * Method to show box |
|
204 | - * |
|
205 | - * @param array $head Array with properties of box title |
|
206 | - * @param array $contents Array with properties of box lines |
|
207 | - * @param int $nooutput No print, only return string |
|
208 | - * @return string |
|
209 | - */ |
|
199 | + } |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * Method to show box |
|
204 | + * |
|
205 | + * @param array $head Array with properties of box title |
|
206 | + * @param array $contents Array with properties of box lines |
|
207 | + * @param int $nooutput No print, only return string |
|
208 | + * @return string |
|
209 | + */ |
|
210 | 210 | function showBox($head = null, $contents = null, $nooutput=0) |
211 | 211 | { |
212 | - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
213 | - } |
|
212 | + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
213 | + } |
|
214 | 214 | } |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class box_factures_imp extends ModeleBoxes |
35 | 35 | { |
36 | - var $boxcode="oldestunpaidcustomerbills"; |
|
37 | - var $boximg="object_bill"; |
|
38 | - var $boxlabel="BoxOldestUnpaidCustomerBills"; |
|
36 | + var $boxcode = "oldestunpaidcustomerbills"; |
|
37 | + var $boximg = "object_bill"; |
|
38 | + var $boxlabel = "BoxOldestUnpaidCustomerBills"; |
|
39 | 39 | var $depends = array("facture"); |
40 | 40 | |
41 | 41 | /** |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | * @param DoliDB $db Database handler |
56 | 56 | * @param string $param More parameters |
57 | 57 | */ |
58 | - function __construct($db,$param) |
|
58 | + function __construct($db, $param) |
|
59 | 59 | { |
60 | 60 | global $user; |
61 | 61 | |
62 | - $this->db=$db; |
|
62 | + $this->db = $db; |
|
63 | 63 | |
64 | - $this->hidden=! ($user->rights->facture->lire); |
|
64 | + $this->hidden = !($user->rights->facture->lire); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | * @param int $max Maximum number of records to load |
71 | 71 | * @return void |
72 | 72 | */ |
73 | - function loadBox($max=5) |
|
73 | + function loadBox($max = 5) |
|
74 | 74 | { |
75 | 75 | global $conf, $user, $langs, $db; |
76 | 76 | |
77 | - $this->max=$max; |
|
77 | + $this->max = $max; |
|
78 | 78 | |
79 | 79 | include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
80 | 80 | include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
@@ -82,42 +82,42 @@ discard block |
||
82 | 82 | $facturestatic = new Facture($db); |
83 | 83 | $societestatic = new Societe($db); |
84 | 84 | |
85 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidCustomerBills",$max)); |
|
85 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidCustomerBills", $max)); |
|
86 | 86 | |
87 | 87 | if ($user->rights->facture->lire) |
88 | 88 | { |
89 | 89 | $sql = "SELECT s.nom as name, s.rowid as socid, s.email,"; |
90 | - $sql.= " s.code_client,"; |
|
91 | - $sql.= " s.logo,"; |
|
92 | - $sql.= " f.ref, f.date_lim_reglement as datelimite,"; |
|
93 | - $sql.= " f.type,"; |
|
94 | - $sql.= " f.amount, f.datef as df,"; |
|
95 | - $sql.= " f.total as total_ht,"; |
|
96 | - $sql.= " f.tva as total_tva,"; |
|
97 | - $sql.= " f.total_ttc,"; |
|
98 | - $sql.= " f.paye, f.fk_statut, f.rowid as facid"; |
|
99 | - $sql.= ", sum(pf.amount) as am"; |
|
100 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
101 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
102 | - $sql.= ", ".MAIN_DB_PREFIX."facture as f"; |
|
103 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; |
|
104 | - $sql.= " WHERE f.fk_soc = s.rowid"; |
|
105 | - $sql.= " AND f.entity = ".$conf->entity; |
|
106 | - $sql.= " AND f.paye = 0"; |
|
107 | - $sql.= " AND fk_statut = 1"; |
|
108 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
109 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
110 | - $sql.= " GROUP BY s.nom, s.rowid, s.code_client, s.logo, f.ref, f.date_lim_reglement,"; |
|
111 | - $sql.= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; |
|
90 | + $sql .= " s.code_client,"; |
|
91 | + $sql .= " s.logo,"; |
|
92 | + $sql .= " f.ref, f.date_lim_reglement as datelimite,"; |
|
93 | + $sql .= " f.type,"; |
|
94 | + $sql .= " f.amount, f.datef as df,"; |
|
95 | + $sql .= " f.total as total_ht,"; |
|
96 | + $sql .= " f.tva as total_tva,"; |
|
97 | + $sql .= " f.total_ttc,"; |
|
98 | + $sql .= " f.paye, f.fk_statut, f.rowid as facid"; |
|
99 | + $sql .= ", sum(pf.amount) as am"; |
|
100 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
101 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
102 | + $sql .= ", ".MAIN_DB_PREFIX."facture as f"; |
|
103 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; |
|
104 | + $sql .= " WHERE f.fk_soc = s.rowid"; |
|
105 | + $sql .= " AND f.entity = ".$conf->entity; |
|
106 | + $sql .= " AND f.paye = 0"; |
|
107 | + $sql .= " AND fk_statut = 1"; |
|
108 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
109 | + if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id; |
|
110 | + $sql .= " GROUP BY s.nom, s.rowid, s.code_client, s.logo, f.ref, f.date_lim_reglement,"; |
|
111 | + $sql .= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; |
|
112 | 112 | //$sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
113 | - $sql.= " ORDER BY datelimite ASC, f.ref ASC "; |
|
114 | - $sql.= $db->plimit($max, 0); |
|
113 | + $sql .= " ORDER BY datelimite ASC, f.ref ASC "; |
|
114 | + $sql .= $db->plimit($max, 0); |
|
115 | 115 | |
116 | 116 | $result = $db->query($sql); |
117 | 117 | if ($result) |
118 | 118 | { |
119 | 119 | $num = $db->num_rows($result); |
120 | - $now=dol_now(); |
|
120 | + $now = dol_now(); |
|
121 | 121 | |
122 | 122 | $line = 0; |
123 | 123 | $l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateDue')).': %s)'; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | while ($line < $num) |
126 | 126 | { |
127 | 127 | $objp = $db->fetch_object($result); |
128 | - $datelimite=$db->jdate($objp->datelimite); |
|
128 | + $datelimite = $db->jdate($objp->datelimite); |
|
129 | 129 | $facturestatic->id = $objp->facid; |
130 | 130 | $facturestatic->ref = $objp->ref; |
131 | 131 | $facturestatic->type = $objp->type; |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | $societestatic->code_client = $objp->code_client; |
143 | 143 | $societestatic->logo = $objp->logo; |
144 | 144 | |
145 | - $late=''; |
|
145 | + $late = ''; |
|
146 | 146 | if ($facturestatic->hasDelay()) { |
147 | - $late = img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day'))); |
|
147 | + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | $this->info_box_contents[$line][] = array( |
@@ -167,18 +167,18 @@ discard block |
||
167 | 167 | |
168 | 168 | $this->info_box_contents[$line][] = array( |
169 | 169 | 'td' => 'class="right"', |
170 | - 'text' => dol_print_date($datelimite,'day'), |
|
170 | + 'text' => dol_print_date($datelimite, 'day'), |
|
171 | 171 | ); |
172 | 172 | |
173 | 173 | $this->info_box_contents[$line][] = array( |
174 | 174 | 'td' => 'align="right" width="18"', |
175 | - 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$objp->am), |
|
175 | + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $objp->am), |
|
176 | 176 | ); |
177 | 177 | |
178 | 178 | $line++; |
179 | 179 | } |
180 | 180 | |
181 | - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoUnpaidCustomerBills")); |
|
181 | + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text'=>$langs->trans("NoUnpaidCustomerBills")); |
|
182 | 182 | |
183 | 183 | $db->free($result); |
184 | 184 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @param int $nooutput No print, only return string |
208 | 208 | * @return string |
209 | 209 | */ |
210 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
210 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
211 | 211 | { |
212 | 212 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
213 | 213 | } |
@@ -98,15 +98,21 @@ discard block |
||
98 | 98 | $sql.= " f.paye, f.fk_statut, f.rowid as facid"; |
99 | 99 | $sql.= ", sum(pf.amount) as am"; |
100 | 100 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
101 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
101 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
102 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
103 | + } |
|
102 | 104 | $sql.= ", ".MAIN_DB_PREFIX."facture as f"; |
103 | 105 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; |
104 | 106 | $sql.= " WHERE f.fk_soc = s.rowid"; |
105 | 107 | $sql.= " AND f.entity = ".$conf->entity; |
106 | 108 | $sql.= " AND f.paye = 0"; |
107 | 109 | $sql.= " AND fk_statut = 1"; |
108 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
109 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
110 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
111 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
112 | + } |
|
113 | + if($user->societe_id) { |
|
114 | + $sql.= " AND s.rowid = ".$user->societe_id; |
|
115 | + } |
|
110 | 116 | $sql.= " GROUP BY s.nom, s.rowid, s.code_client, s.logo, f.ref, f.date_lim_reglement,"; |
111 | 117 | $sql.= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; |
112 | 118 | //$sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
@@ -178,11 +184,12 @@ discard block |
||
178 | 184 | $line++; |
179 | 185 | } |
180 | 186 | |
181 | - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoUnpaidCustomerBills")); |
|
187 | + if ($num==0) { |
|
188 | + $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoUnpaidCustomerBills")); |
|
189 | + } |
|
182 | 190 | |
183 | 191 | $db->free($result); |
184 | - } |
|
185 | - else |
|
192 | + } else |
|
186 | 193 | { |
187 | 194 | $this->info_box_contents[0][0] = array( |
188 | 195 | 'td' => '', |
@@ -190,8 +197,7 @@ discard block |
||
190 | 197 | 'text' => ($db->error().' sql='.$sql), |
191 | 198 | ); |
192 | 199 | } |
193 | - } |
|
194 | - else { |
|
200 | + } else { |
|
195 | 201 | $this->info_box_contents[0][0] = array( |
196 | 202 | 'td' => 'align="left" class="nohover opacitymedium"', |
197 | 203 | 'text' => $langs->trans("ReadPermissionNotAllowed") |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | var $boxlabel="BoxLastRssInfos"; |
40 | 40 | var $depends = array("externalrss"); |
41 | 41 | |
42 | - /** |
|
42 | + /** |
|
43 | 43 | * @var DoliDB Database handler. |
44 | 44 | */ |
45 | 45 | public $db; |
46 | 46 | |
47 | - var $paramdef; // Params of box definition (not user params) |
|
47 | + var $paramdef; // Params of box definition (not user params) |
|
48 | 48 | |
49 | 49 | var $info_box_head = array(); |
50 | 50 | var $info_box_contents = array(); |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | */ |
59 | 59 | function __construct($db,$param) |
60 | 60 | { |
61 | - $this->db=$db; |
|
62 | - $this->paramdef=$param; |
|
61 | + $this->db=$db; |
|
62 | + $this->paramdef=$param; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
66 | - * Load data into info_box_contents array to show array later. |
|
67 | - * |
|
68 | - * @param int $max Maximum number of records to load |
|
66 | + * Load data into info_box_contents array to show array later. |
|
67 | + * |
|
68 | + * @param int $max Maximum number of records to load |
|
69 | 69 | * @param int $cachedelay Delay we accept for cache file |
70 | 70 | * @return void |
71 | 71 | */ |
@@ -74,28 +74,28 @@ discard block |
||
74 | 74 | global $user, $langs, $conf; |
75 | 75 | $langs->load("boxes"); |
76 | 76 | |
77 | - $this->max=$max; |
|
77 | + $this->max=$max; |
|
78 | 78 | |
79 | - // On recupere numero de param de la boite |
|
80 | - preg_match('/^([0-9]+) /',$this->paramdef,$reg); |
|
81 | - $site=$reg[1]; |
|
79 | + // On recupere numero de param de la boite |
|
80 | + preg_match('/^([0-9]+) /',$this->paramdef,$reg); |
|
81 | + $site=$reg[1]; |
|
82 | 82 | |
83 | - // Create dir nor required |
|
84 | - // documents/externalrss is created by module activation |
|
85 | - // documents/externalrss/tmp is created by rssparser |
|
83 | + // Create dir nor required |
|
84 | + // documents/externalrss is created by module activation |
|
85 | + // documents/externalrss/tmp is created by rssparser |
|
86 | 86 | |
87 | - $keyforparamurl="EXTERNAL_RSS_URLRSS_".$site; |
|
88 | - $keyforparamtitle="EXTERNAL_RSS_TITLE_".$site; |
|
87 | + $keyforparamurl="EXTERNAL_RSS_URLRSS_".$site; |
|
88 | + $keyforparamtitle="EXTERNAL_RSS_TITLE_".$site; |
|
89 | 89 | |
90 | - // Get RSS feed |
|
91 | - $url=$conf->global->$keyforparamurl; |
|
90 | + // Get RSS feed |
|
91 | + $url=$conf->global->$keyforparamurl; |
|
92 | 92 | |
93 | 93 | $rssparser=new RssParser($this->db); |
94 | - $result = $rssparser->parser($url, $this->max, $cachedelay, $conf->externalrss->dir_temp); |
|
94 | + $result = $rssparser->parser($url, $this->max, $cachedelay, $conf->externalrss->dir_temp); |
|
95 | 95 | |
96 | - // INFO on channel |
|
97 | - $description=$rssparser->getDescription(); |
|
98 | - $link=$rssparser->getLink(); |
|
96 | + // INFO on channel |
|
97 | + $description=$rssparser->getDescription(); |
|
98 | + $link=$rssparser->getLink(); |
|
99 | 99 | |
100 | 100 | $title=$langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); |
101 | 101 | if ($result < 0 || ! empty($rssparser->error)) |
@@ -111,42 +111,42 @@ discard block |
||
111 | 111 | 'sublink' => $link, |
112 | 112 | 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate()?dol_print_date($rssparser->getLastFetchDate(),"dayhourtext"):$langs->trans("Unknown")), |
113 | 113 | 'subpicto'=>'help', |
114 | - 'target'=>'_blank', |
|
114 | + 'target'=>'_blank', |
|
115 | 115 | ); |
116 | - } |
|
116 | + } |
|
117 | 117 | |
118 | - // INFO on items |
|
119 | - $items=$rssparser->getItems(); |
|
118 | + // INFO on items |
|
119 | + $items=$rssparser->getItems(); |
|
120 | 120 | //print '<pre>'.print_r($items,true).'</pre>'; |
121 | - $nbitems=count($items); |
|
121 | + $nbitems=count($items); |
|
122 | 122 | for($line = 0; $line < $max && $line < $nbitems; $line++) |
123 | 123 | { |
124 | 124 | $item = $items[$line]; |
125 | 125 | |
126 | - // Feed common fields |
|
126 | + // Feed common fields |
|
127 | 127 | $href = $item['link']; |
128 | - $title = urldecode($item['title']); |
|
129 | - $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed |
|
130 | - if ($rssparser->getFormat() == 'rss') // If RSS |
|
131 | - { |
|
132 | - if (! $date && isset($item['pubdate'])) $date=$item['pubdate']; |
|
133 | - if (! $date && isset($item['dc']['date'])) $date=$item['dc']['date']; |
|
134 | - //$item['dc']['language'] |
|
135 | - //$item['dc']['publisher'] |
|
136 | - } |
|
137 | - if ($rssparser->getFormat() == 'atom') // If Atom |
|
138 | - { |
|
139 | - if (! $date && isset($item['issued'])) $date=$item['issued']; |
|
140 | - if (! $date && isset($item['modified'])) $date=$item['modified']; |
|
141 | - //$item['issued'] |
|
142 | - //$item['modified'] |
|
143 | - //$item['atom_content'] |
|
144 | - } |
|
145 | - if (is_numeric($date)) $date=dol_print_date($date,"dayhour"); |
|
146 | - |
|
147 | - $isutf8 = utf8_check($title); |
|
148 | - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') $title=utf8_encode($title); |
|
149 | - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title=utf8_decode($title); |
|
128 | + $title = urldecode($item['title']); |
|
129 | + $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed |
|
130 | + if ($rssparser->getFormat() == 'rss') // If RSS |
|
131 | + { |
|
132 | + if (! $date && isset($item['pubdate'])) $date=$item['pubdate']; |
|
133 | + if (! $date && isset($item['dc']['date'])) $date=$item['dc']['date']; |
|
134 | + //$item['dc']['language'] |
|
135 | + //$item['dc']['publisher'] |
|
136 | + } |
|
137 | + if ($rssparser->getFormat() == 'atom') // If Atom |
|
138 | + { |
|
139 | + if (! $date && isset($item['issued'])) $date=$item['issued']; |
|
140 | + if (! $date && isset($item['modified'])) $date=$item['modified']; |
|
141 | + //$item['issued'] |
|
142 | + //$item['modified'] |
|
143 | + //$item['atom_content'] |
|
144 | + } |
|
145 | + if (is_numeric($date)) $date=dol_print_date($date,"dayhour"); |
|
146 | + |
|
147 | + $isutf8 = utf8_check($title); |
|
148 | + if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') $title=utf8_encode($title); |
|
149 | + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title=utf8_decode($title); |
|
150 | 150 | |
151 | 151 | $title=preg_replace("/([[:alnum:]])\?([[:alnum:]])/","\\1'\\2",$title); // Gere probleme des apostrophes mal codee/decodee par utf8 |
152 | 152 | $title=preg_replace("/^\s+/","",$title); // Supprime espaces de debut |
@@ -187,14 +187,14 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | |
190 | - /** |
|
191 | - * Method to show box |
|
192 | - * |
|
193 | - * @param array $head Array with properties of box title |
|
194 | - * @param array $contents Array with properties of box lines |
|
195 | - * @param int $nooutput No print, only return string |
|
196 | - * @return string |
|
197 | - */ |
|
190 | + /** |
|
191 | + * Method to show box |
|
192 | + * |
|
193 | + * @param array $head Array with properties of box title |
|
194 | + * @param array $contents Array with properties of box lines |
|
195 | + * @param int $nooutput No print, only return string |
|
196 | + * @return string |
|
197 | + */ |
|
198 | 198 | function showBox($head = null, $contents = null, $nooutput=0) |
199 | 199 | { |
200 | 200 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | */ |
35 | 35 | class box_external_rss extends ModeleBoxes |
36 | 36 | { |
37 | - var $boxcode="lastrssinfos"; |
|
38 | - var $boximg="object_rss"; |
|
39 | - var $boxlabel="BoxLastRssInfos"; |
|
37 | + var $boxcode = "lastrssinfos"; |
|
38 | + var $boximg = "object_rss"; |
|
39 | + var $boxlabel = "BoxLastRssInfos"; |
|
40 | 40 | var $depends = array("externalrss"); |
41 | 41 | |
42 | 42 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public $db; |
46 | 46 | |
47 | - var $paramdef; // Params of box definition (not user params) |
|
47 | + var $paramdef; // Params of box definition (not user params) |
|
48 | 48 | |
49 | 49 | var $info_box_head = array(); |
50 | 50 | var $info_box_contents = array(); |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | * @param DoliDB $db Database handler |
57 | 57 | * @param string $param More parameters |
58 | 58 | */ |
59 | - function __construct($db,$param) |
|
59 | + function __construct($db, $param) |
|
60 | 60 | { |
61 | - $this->db=$db; |
|
62 | - $this->paramdef=$param; |
|
61 | + $this->db = $db; |
|
62 | + $this->paramdef = $param; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -69,98 +69,98 @@ discard block |
||
69 | 69 | * @param int $cachedelay Delay we accept for cache file |
70 | 70 | * @return void |
71 | 71 | */ |
72 | - function loadBox($max=5, $cachedelay=3600) |
|
72 | + function loadBox($max = 5, $cachedelay = 3600) |
|
73 | 73 | { |
74 | 74 | global $user, $langs, $conf; |
75 | 75 | $langs->load("boxes"); |
76 | 76 | |
77 | - $this->max=$max; |
|
77 | + $this->max = $max; |
|
78 | 78 | |
79 | 79 | // On recupere numero de param de la boite |
80 | - preg_match('/^([0-9]+) /',$this->paramdef,$reg); |
|
81 | - $site=$reg[1]; |
|
80 | + preg_match('/^([0-9]+) /', $this->paramdef, $reg); |
|
81 | + $site = $reg[1]; |
|
82 | 82 | |
83 | 83 | // Create dir nor required |
84 | 84 | // documents/externalrss is created by module activation |
85 | 85 | // documents/externalrss/tmp is created by rssparser |
86 | 86 | |
87 | - $keyforparamurl="EXTERNAL_RSS_URLRSS_".$site; |
|
88 | - $keyforparamtitle="EXTERNAL_RSS_TITLE_".$site; |
|
87 | + $keyforparamurl = "EXTERNAL_RSS_URLRSS_".$site; |
|
88 | + $keyforparamtitle = "EXTERNAL_RSS_TITLE_".$site; |
|
89 | 89 | |
90 | 90 | // Get RSS feed |
91 | - $url=$conf->global->$keyforparamurl; |
|
91 | + $url = $conf->global->$keyforparamurl; |
|
92 | 92 | |
93 | - $rssparser=new RssParser($this->db); |
|
93 | + $rssparser = new RssParser($this->db); |
|
94 | 94 | $result = $rssparser->parser($url, $this->max, $cachedelay, $conf->externalrss->dir_temp); |
95 | 95 | |
96 | 96 | // INFO on channel |
97 | - $description=$rssparser->getDescription(); |
|
98 | - $link=$rssparser->getLink(); |
|
97 | + $description = $rssparser->getDescription(); |
|
98 | + $link = $rssparser->getLink(); |
|
99 | 99 | |
100 | - $title=$langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); |
|
101 | - if ($result < 0 || ! empty($rssparser->error)) |
|
100 | + $title = $langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle); |
|
101 | + if ($result < 0 || !empty($rssparser->error)) |
|
102 | 102 | { |
103 | 103 | // Show warning |
104 | - $title.=" ".img_error($langs->trans("FailedToRefreshDataInfoNotUpToDate",($rssparser->getLastFetchDate()?dol_print_date($rssparser->getLastFetchDate(),"dayhourtext"):$langs->trans("Unknown")))); |
|
105 | - $this->info_box_head = array('text' => $title,'limit' => 0); |
|
104 | + $title .= " ".img_error($langs->trans("FailedToRefreshDataInfoNotUpToDate", ($rssparser->getLastFetchDate() ?dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")))); |
|
105 | + $this->info_box_head = array('text' => $title, 'limit' => 0); |
|
106 | 106 | } |
107 | 107 | else |
108 | 108 | { |
109 | 109 | $this->info_box_head = array( |
110 | 110 | 'text' => $title, |
111 | 111 | 'sublink' => $link, |
112 | - 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate()?dol_print_date($rssparser->getLastFetchDate(),"dayhourtext"):$langs->trans("Unknown")), |
|
112 | + 'subtext'=>$langs->trans("LastRefreshDate").': '.($rssparser->getLastFetchDate() ?dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")), |
|
113 | 113 | 'subpicto'=>'help', |
114 | 114 | 'target'=>'_blank', |
115 | 115 | ); |
116 | 116 | } |
117 | 117 | |
118 | 118 | // INFO on items |
119 | - $items=$rssparser->getItems(); |
|
119 | + $items = $rssparser->getItems(); |
|
120 | 120 | //print '<pre>'.print_r($items,true).'</pre>'; |
121 | - $nbitems=count($items); |
|
122 | - for($line = 0; $line < $max && $line < $nbitems; $line++) |
|
121 | + $nbitems = count($items); |
|
122 | + for ($line = 0; $line < $max && $line < $nbitems; $line++) |
|
123 | 123 | { |
124 | 124 | $item = $items[$line]; |
125 | 125 | |
126 | 126 | // Feed common fields |
127 | - $href = $item['link']; |
|
127 | + $href = $item['link']; |
|
128 | 128 | $title = urldecode($item['title']); |
129 | - $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed |
|
129 | + $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed |
|
130 | 130 | if ($rssparser->getFormat() == 'rss') // If RSS |
131 | 131 | { |
132 | - if (! $date && isset($item['pubdate'])) $date=$item['pubdate']; |
|
133 | - if (! $date && isset($item['dc']['date'])) $date=$item['dc']['date']; |
|
132 | + if (!$date && isset($item['pubdate'])) $date = $item['pubdate']; |
|
133 | + if (!$date && isset($item['dc']['date'])) $date = $item['dc']['date']; |
|
134 | 134 | //$item['dc']['language'] |
135 | 135 | //$item['dc']['publisher'] |
136 | 136 | } |
137 | 137 | if ($rssparser->getFormat() == 'atom') // If Atom |
138 | 138 | { |
139 | - if (! $date && isset($item['issued'])) $date=$item['issued']; |
|
140 | - if (! $date && isset($item['modified'])) $date=$item['modified']; |
|
139 | + if (!$date && isset($item['issued'])) $date = $item['issued']; |
|
140 | + if (!$date && isset($item['modified'])) $date = $item['modified']; |
|
141 | 141 | //$item['issued'] |
142 | 142 | //$item['modified'] |
143 | 143 | //$item['atom_content'] |
144 | 144 | } |
145 | - if (is_numeric($date)) $date=dol_print_date($date,"dayhour"); |
|
145 | + if (is_numeric($date)) $date = dol_print_date($date, "dayhour"); |
|
146 | 146 | |
147 | 147 | $isutf8 = utf8_check($title); |
148 | - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') $title=utf8_encode($title); |
|
149 | - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title=utf8_decode($title); |
|
148 | + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $title = utf8_encode($title); |
|
149 | + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title = utf8_decode($title); |
|
150 | 150 | |
151 | - $title=preg_replace("/([[:alnum:]])\?([[:alnum:]])/","\\1'\\2",$title); // Gere probleme des apostrophes mal codee/decodee par utf8 |
|
152 | - $title=preg_replace("/^\s+/","",$title); // Supprime espaces de debut |
|
153 | - $this->info_box_contents["$href"]="$title"; |
|
151 | + $title = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $title); // Gere probleme des apostrophes mal codee/decodee par utf8 |
|
152 | + $title = preg_replace("/^\s+/", "", $title); // Supprime espaces de debut |
|
153 | + $this->info_box_contents["$href"] = "$title"; |
|
154 | 154 | |
155 | 155 | $tooltip = $title; |
156 | - $description = ! empty($item['description'])?$item['description']:''; |
|
156 | + $description = !empty($item['description']) ? $item['description'] : ''; |
|
157 | 157 | $isutf8 = utf8_check($description); |
158 | - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') $description=utf8_encode($description); |
|
159 | - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $description=utf8_decode($description); |
|
160 | - $description=preg_replace("/([[:alnum:]])\?([[:alnum:]])/","\\1'\\2",$description); |
|
161 | - $description=preg_replace("/^\s+/","",$description); |
|
162 | - $description=str_replace("\r\n","",$description); |
|
163 | - $tooltip.= '<br>'.$description; |
|
158 | + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $description = utf8_encode($description); |
|
159 | + elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $description = utf8_decode($description); |
|
160 | + $description = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $description); |
|
161 | + $description = preg_replace("/^\s+/", "", $description); |
|
162 | + $description = str_replace("\r\n", "", $description); |
|
163 | + $tooltip .= '<br>'.$description; |
|
164 | 164 | |
165 | 165 | $this->info_box_contents[$line][0] = array( |
166 | 166 | 'td' => 'align="left" width="16"', |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param int $nooutput No print, only return string |
196 | 196 | * @return string |
197 | 197 | */ |
198 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
198 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
199 | 199 | { |
200 | 200 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
201 | 201 | } |
@@ -103,8 +103,7 @@ discard block |
||
103 | 103 | // Show warning |
104 | 104 | $title.=" ".img_error($langs->trans("FailedToRefreshDataInfoNotUpToDate",($rssparser->getLastFetchDate()?dol_print_date($rssparser->getLastFetchDate(),"dayhourtext"):$langs->trans("Unknown")))); |
105 | 105 | $this->info_box_head = array('text' => $title,'limit' => 0); |
106 | - } |
|
107 | - else |
|
106 | + } else |
|
108 | 107 | { |
109 | 108 | $this->info_box_head = array( |
110 | 109 | 'text' => $title, |
@@ -127,26 +126,39 @@ discard block |
||
127 | 126 | $href = $item['link']; |
128 | 127 | $title = urldecode($item['title']); |
129 | 128 | $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed |
130 | - if ($rssparser->getFormat() == 'rss') // If RSS |
|
129 | + if ($rssparser->getFormat() == 'rss') { |
|
130 | + // If RSS |
|
131 | 131 | { |
132 | 132 | if (! $date && isset($item['pubdate'])) $date=$item['pubdate']; |
133 | - if (! $date && isset($item['dc']['date'])) $date=$item['dc']['date']; |
|
133 | + } |
|
134 | + if (! $date && isset($item['dc']['date'])) { |
|
135 | + $date=$item['dc']['date']; |
|
136 | + } |
|
134 | 137 | //$item['dc']['language'] |
135 | 138 | //$item['dc']['publisher'] |
136 | 139 | } |
137 | - if ($rssparser->getFormat() == 'atom') // If Atom |
|
140 | + if ($rssparser->getFormat() == 'atom') { |
|
141 | + // If Atom |
|
138 | 142 | { |
139 | 143 | if (! $date && isset($item['issued'])) $date=$item['issued']; |
140 | - if (! $date && isset($item['modified'])) $date=$item['modified']; |
|
144 | + } |
|
145 | + if (! $date && isset($item['modified'])) { |
|
146 | + $date=$item['modified']; |
|
147 | + } |
|
141 | 148 | //$item['issued'] |
142 | 149 | //$item['modified'] |
143 | 150 | //$item['atom_content'] |
144 | 151 | } |
145 | - if (is_numeric($date)) $date=dol_print_date($date,"dayhour"); |
|
152 | + if (is_numeric($date)) { |
|
153 | + $date=dol_print_date($date,"dayhour"); |
|
154 | + } |
|
146 | 155 | |
147 | 156 | $isutf8 = utf8_check($title); |
148 | - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') $title=utf8_encode($title); |
|
149 | - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title=utf8_decode($title); |
|
157 | + if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') { |
|
158 | + $title=utf8_encode($title); |
|
159 | + } elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') { |
|
160 | + $title=utf8_decode($title); |
|
161 | + } |
|
150 | 162 | |
151 | 163 | $title=preg_replace("/([[:alnum:]])\?([[:alnum:]])/","\\1'\\2",$title); // Gere probleme des apostrophes mal codee/decodee par utf8 |
152 | 164 | $title=preg_replace("/^\s+/","",$title); // Supprime espaces de debut |
@@ -155,8 +167,11 @@ discard block |
||
155 | 167 | $tooltip = $title; |
156 | 168 | $description = ! empty($item['description'])?$item['description']:''; |
157 | 169 | $isutf8 = utf8_check($description); |
158 | - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') $description=utf8_encode($description); |
|
159 | - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $description=utf8_decode($description); |
|
170 | + if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') { |
|
171 | + $description=utf8_encode($description); |
|
172 | + } elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') { |
|
173 | + $description=utf8_decode($description); |
|
174 | + } |
|
160 | 175 | $description=preg_replace("/([[:alnum:]])\?([[:alnum:]])/","\\1'\\2",$description); |
161 | 176 | $description=preg_replace("/^\s+/","",$description); |
162 | 177 | $description=str_replace("\r\n","",$description); |
@@ -30,48 +30,48 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class box_factures extends ModeleBoxes |
32 | 32 | { |
33 | - var $boxcode="lastcustomerbills"; |
|
34 | - var $boximg="object_bill"; |
|
35 | - var $boxlabel="BoxLastCustomerBills"; |
|
36 | - var $depends = array("facture"); |
|
33 | + var $boxcode="lastcustomerbills"; |
|
34 | + var $boximg="object_bill"; |
|
35 | + var $boxlabel="BoxLastCustomerBills"; |
|
36 | + var $depends = array("facture"); |
|
37 | 37 | |
38 | - /** |
|
38 | + /** |
|
39 | 39 | * @var DoliDB Database handler. |
40 | 40 | */ |
41 | 41 | public $db; |
42 | 42 | |
43 | - var $param; |
|
43 | + var $param; |
|
44 | 44 | |
45 | - var $info_box_head = array(); |
|
46 | - var $info_box_contents = array(); |
|
45 | + var $info_box_head = array(); |
|
46 | + var $info_box_contents = array(); |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * Constructor |
|
51 | - * |
|
52 | - * @param DoliDB $db Database handler |
|
53 | - * @param string $param More parameters |
|
54 | - */ |
|
55 | - function __construct($db,$param) |
|
56 | - { |
|
57 | - global $user; |
|
49 | + /** |
|
50 | + * Constructor |
|
51 | + * |
|
52 | + * @param DoliDB $db Database handler |
|
53 | + * @param string $param More parameters |
|
54 | + */ |
|
55 | + function __construct($db,$param) |
|
56 | + { |
|
57 | + global $user; |
|
58 | 58 | |
59 | - $this->db=$db; |
|
59 | + $this->db=$db; |
|
60 | 60 | |
61 | - $this->hidden=! ($user->rights->facture->lire); |
|
62 | - } |
|
61 | + $this->hidden=! ($user->rights->facture->lire); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Load data into info_box_contents array to show array later. |
|
66 | - * |
|
67 | - * @param int $max Maximum number of records to load |
|
64 | + /** |
|
65 | + * Load data into info_box_contents array to show array later. |
|
66 | + * |
|
67 | + * @param int $max Maximum number of records to load |
|
68 | 68 | * @return void |
69 | - */ |
|
70 | - function loadBox($max=5) |
|
71 | - { |
|
72 | - global $conf, $user, $langs, $db; |
|
69 | + */ |
|
70 | + function loadBox($max=5) |
|
71 | + { |
|
72 | + global $conf, $user, $langs, $db; |
|
73 | 73 | |
74 | - $this->max=$max; |
|
74 | + $this->max=$max; |
|
75 | 75 | |
76 | 76 | include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
77 | 77 | include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | |
82 | 82 | $langs->load("bills"); |
83 | 83 | |
84 | - $text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerBills",$max); |
|
85 | - $this->info_box_head = array( |
|
86 | - 'text' => $text, |
|
87 | - 'limit'=> dol_strlen($text) |
|
88 | - ); |
|
84 | + $text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerBills",$max); |
|
85 | + $this->info_box_head = array( |
|
86 | + 'text' => $text, |
|
87 | + 'limit'=> dol_strlen($text) |
|
88 | + ); |
|
89 | 89 | |
90 | 90 | if ($user->rights->facture->lire) { |
91 | 91 | $sql = "SELECT f.rowid as facid"; |
@@ -93,28 +93,28 @@ discard block |
||
93 | 93 | $sql.= ", f.tva as total_tva"; |
94 | 94 | $sql.= ", f.total_ttc"; |
95 | 95 | $sql.= ", f.datef as df"; |
96 | - $sql.= ", f.paye, f.fk_statut, f.datec, f.tms"; |
|
96 | + $sql.= ", f.paye, f.fk_statut, f.datec, f.tms"; |
|
97 | 97 | $sql.= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; |
98 | - $sql.= ", f.date_lim_reglement as datelimite"; |
|
99 | - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; |
|
100 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
101 | - $sql.= ")"; |
|
102 | - $sql.= " WHERE f.fk_soc = s.rowid"; |
|
103 | - $sql.= " AND f.entity = ".$conf->entity; |
|
104 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
105 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
98 | + $sql.= ", f.date_lim_reglement as datelimite"; |
|
99 | + $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; |
|
100 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
101 | + $sql.= ")"; |
|
102 | + $sql.= " WHERE f.fk_soc = s.rowid"; |
|
103 | + $sql.= " AND f.entity = ".$conf->entity; |
|
104 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
105 | + if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
106 | 106 | if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
107 | 107 | else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; |
108 | - $sql.= $db->plimit($max, 0); |
|
108 | + $sql.= $db->plimit($max, 0); |
|
109 | 109 | |
110 | - $result = $db->query($sql); |
|
111 | - if ($result) |
|
112 | - { |
|
113 | - $num = $db->num_rows($result); |
|
114 | - $now=dol_now(); |
|
110 | + $result = $db->query($sql); |
|
111 | + if ($result) |
|
112 | + { |
|
113 | + $num = $db->num_rows($result); |
|
114 | + $now=dol_now(); |
|
115 | 115 | |
116 | - $line = 0; |
|
117 | - $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; |
|
116 | + $line = 0; |
|
117 | + $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; |
|
118 | 118 | |
119 | 119 | while ($line < $num) { |
120 | 120 | $objp = $db->fetch_object($result); |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | $societestatic->idprof5 = $objp->idprof5; |
144 | 144 | $societestatic->idprof6 = $objp->idprof6; |
145 | 145 | |
146 | - $late = ''; |
|
147 | - if ($facturestatic->hasDelay()) { |
|
146 | + $late = ''; |
|
147 | + if ($facturestatic->hasDelay()) { |
|
148 | 148 | $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite,'day'))); |
149 | 149 | } |
150 | 150 | |
@@ -201,16 +201,16 @@ discard block |
||
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | - /** |
|
205 | - * Method to show box |
|
206 | - * |
|
207 | - * @param array $head Array with properties of box title |
|
208 | - * @param array $contents Array with properties of box lines |
|
209 | - * @param int $nooutput No print, only return string |
|
210 | - * @return string |
|
211 | - */ |
|
204 | + /** |
|
205 | + * Method to show box |
|
206 | + * |
|
207 | + * @param array $head Array with properties of box title |
|
208 | + * @param array $contents Array with properties of box lines |
|
209 | + * @param int $nooutput No print, only return string |
|
210 | + * @return string |
|
211 | + */ |
|
212 | 212 | function showBox($head = null, $contents = null, $nooutput=0) |
213 | 213 | { |
214 | - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
215 | - } |
|
214 | + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
215 | + } |
|
216 | 216 | } |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class box_factures extends ModeleBoxes |
32 | 32 | { |
33 | - var $boxcode="lastcustomerbills"; |
|
34 | - var $boximg="object_bill"; |
|
35 | - var $boxlabel="BoxLastCustomerBills"; |
|
33 | + var $boxcode = "lastcustomerbills"; |
|
34 | + var $boximg = "object_bill"; |
|
35 | + var $boxlabel = "BoxLastCustomerBills"; |
|
36 | 36 | var $depends = array("facture"); |
37 | 37 | |
38 | 38 | /** |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | * @param DoliDB $db Database handler |
53 | 53 | * @param string $param More parameters |
54 | 54 | */ |
55 | - function __construct($db,$param) |
|
55 | + function __construct($db, $param) |
|
56 | 56 | { |
57 | 57 | global $user; |
58 | 58 | |
59 | - $this->db=$db; |
|
59 | + $this->db = $db; |
|
60 | 60 | |
61 | - $this->hidden=! ($user->rights->facture->lire); |
|
61 | + $this->hidden = !($user->rights->facture->lire); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | * @param int $max Maximum number of records to load |
68 | 68 | * @return void |
69 | 69 | */ |
70 | - function loadBox($max=5) |
|
70 | + function loadBox($max = 5) |
|
71 | 71 | { |
72 | 72 | global $conf, $user, $langs, $db; |
73 | 73 | |
74 | - $this->max=$max; |
|
74 | + $this->max = $max; |
|
75 | 75 | |
76 | 76 | include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
77 | 77 | include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | $langs->load("bills"); |
83 | 83 | |
84 | - $text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."CustomerBills",$max); |
|
84 | + $text = $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."CustomerBills", $max); |
|
85 | 85 | $this->info_box_head = array( |
86 | 86 | 'text' => $text, |
87 | 87 | 'limit'=> dol_strlen($text) |
@@ -89,29 +89,29 @@ discard block |
||
89 | 89 | |
90 | 90 | if ($user->rights->facture->lire) { |
91 | 91 | $sql = "SELECT f.rowid as facid"; |
92 | - $sql.= ", f.ref, f.type, f.total as total_ht"; |
|
93 | - $sql.= ", f.tva as total_tva"; |
|
94 | - $sql.= ", f.total_ttc"; |
|
95 | - $sql.= ", f.datef as df"; |
|
96 | - $sql.= ", f.paye, f.fk_statut, f.datec, f.tms"; |
|
97 | - $sql.= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; |
|
98 | - $sql.= ", f.date_lim_reglement as datelimite"; |
|
99 | - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; |
|
100 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
101 | - $sql.= ")"; |
|
102 | - $sql.= " WHERE f.fk_soc = s.rowid"; |
|
103 | - $sql.= " AND f.entity = ".$conf->entity; |
|
104 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
105 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
106 | - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
|
107 | - else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; |
|
108 | - $sql.= $db->plimit($max, 0); |
|
92 | + $sql .= ", f.ref, f.type, f.total as total_ht"; |
|
93 | + $sql .= ", f.tva as total_tva"; |
|
94 | + $sql .= ", f.total_ttc"; |
|
95 | + $sql .= ", f.datef as df"; |
|
96 | + $sql .= ", f.paye, f.fk_statut, f.datec, f.tms"; |
|
97 | + $sql .= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; |
|
98 | + $sql .= ", f.date_lim_reglement as datelimite"; |
|
99 | + $sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; |
|
100 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
101 | + $sql .= ")"; |
|
102 | + $sql .= " WHERE f.fk_soc = s.rowid"; |
|
103 | + $sql .= " AND f.entity = ".$conf->entity; |
|
104 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
105 | + if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id; |
|
106 | + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; |
|
107 | + else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; |
|
108 | + $sql .= $db->plimit($max, 0); |
|
109 | 109 | |
110 | 110 | $result = $db->query($sql); |
111 | 111 | if ($result) |
112 | 112 | { |
113 | 113 | $num = $db->num_rows($result); |
114 | - $now=dol_now(); |
|
114 | + $now = dol_now(); |
|
115 | 115 | |
116 | 116 | $line = 0; |
117 | 117 | $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | $late = ''; |
147 | 147 | if ($facturestatic->hasDelay()) { |
148 | - $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite,'day'))); |
|
148 | + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | $this->info_box_contents[$line][] = array( |
@@ -168,18 +168,18 @@ discard block |
||
168 | 168 | |
169 | 169 | $this->info_box_contents[$line][] = array( |
170 | 170 | 'td' => 'class="right"', |
171 | - 'text' => dol_print_date($date,'day'), |
|
171 | + 'text' => dol_print_date($date, 'day'), |
|
172 | 172 | ); |
173 | 173 | |
174 | 174 | $this->info_box_contents[$line][] = array( |
175 | 175 | 'td' => 'align="right" width="18"', |
176 | - 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3), |
|
176 | + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3), |
|
177 | 177 | ); |
178 | 178 | |
179 | 179 | $line++; |
180 | 180 | } |
181 | 181 | |
182 | - if ($num==0) |
|
182 | + if ($num == 0) |
|
183 | 183 | $this->info_box_contents[$line][0] = array( |
184 | 184 | 'td' => 'align="center"', |
185 | 185 | 'text'=>$langs->trans("NoRecordedInvoices"), |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param int $nooutput No print, only return string |
210 | 210 | * @return string |
211 | 211 | */ |
212 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
212 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
213 | 213 | { |
214 | 214 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
215 | 215 | } |
@@ -97,14 +97,23 @@ discard block |
||
97 | 97 | $sql.= ", s.rowid as socid, s.nom as name, s.code_client, s.email, s.tva_intra, s.code_compta, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; |
98 | 98 | $sql.= ", f.date_lim_reglement as datelimite"; |
99 | 99 | $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; |
100 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
100 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
101 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
102 | + } |
|
101 | 103 | $sql.= ")"; |
102 | 104 | $sql.= " WHERE f.fk_soc = s.rowid"; |
103 | 105 | $sql.= " AND f.entity = ".$conf->entity; |
104 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
105 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
106 | - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
|
107 | - else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; |
|
106 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
107 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
108 | + } |
|
109 | + if($user->societe_id) { |
|
110 | + $sql.= " AND s.rowid = ".$user->societe_id; |
|
111 | + } |
|
112 | + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) { |
|
113 | + $sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
|
114 | + } else { |
|
115 | + $sql.= " ORDER BY f.tms DESC, f.ref DESC "; |
|
116 | + } |
|
108 | 117 | $sql.= $db->plimit($max, 0); |
109 | 118 | |
110 | 119 | $result = $db->query($sql); |
@@ -179,11 +188,12 @@ discard block |
||
179 | 188 | $line++; |
180 | 189 | } |
181 | 190 | |
182 | - if ($num==0) |
|
183 | - $this->info_box_contents[$line][0] = array( |
|
191 | + if ($num==0) { |
|
192 | + $this->info_box_contents[$line][0] = array( |
|
184 | 193 | 'td' => 'align="center"', |
185 | 194 | 'text'=>$langs->trans("NoRecordedInvoices"), |
186 | 195 | ); |
196 | + } |
|
187 | 197 | |
188 | 198 | $db->free($result); |
189 | 199 | } else { |
@@ -31,96 +31,96 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class box_factures_fourn extends ModeleBoxes |
33 | 33 | { |
34 | - var $boxcode="lastsupplierbills"; |
|
35 | - var $boximg="object_bill"; |
|
36 | - var $boxlabel="BoxLastSupplierBills"; |
|
37 | - var $depends = array("facture","fournisseur"); |
|
34 | + var $boxcode="lastsupplierbills"; |
|
35 | + var $boximg="object_bill"; |
|
36 | + var $boxlabel="BoxLastSupplierBills"; |
|
37 | + var $depends = array("facture","fournisseur"); |
|
38 | 38 | |
39 | - /** |
|
39 | + /** |
|
40 | 40 | * @var DoliDB Database handler. |
41 | 41 | */ |
42 | 42 | public $db; |
43 | 43 | |
44 | - var $param; |
|
44 | + var $param; |
|
45 | 45 | |
46 | - var $info_box_head = array(); |
|
47 | - var $info_box_contents = array(); |
|
46 | + var $info_box_head = array(); |
|
47 | + var $info_box_contents = array(); |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * Constructor |
|
52 | - * |
|
53 | - * @param DoliDB $db Database handler |
|
54 | - * @param string $param More parameters |
|
55 | - */ |
|
56 | - function __construct($db,$param) |
|
57 | - { |
|
58 | - global $user; |
|
50 | + /** |
|
51 | + * Constructor |
|
52 | + * |
|
53 | + * @param DoliDB $db Database handler |
|
54 | + * @param string $param More parameters |
|
55 | + */ |
|
56 | + function __construct($db,$param) |
|
57 | + { |
|
58 | + global $user; |
|
59 | 59 | |
60 | - $this->db=$db; |
|
60 | + $this->db=$db; |
|
61 | 61 | |
62 | - $this->hidden=! ($user->rights->fournisseur->facture->lire); |
|
63 | - } |
|
62 | + $this->hidden=! ($user->rights->fournisseur->facture->lire); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Load data into info_box_contents array to show array later. |
|
67 | - * |
|
68 | - * @param int $max Maximum number of records to load |
|
65 | + /** |
|
66 | + * Load data into info_box_contents array to show array later. |
|
67 | + * |
|
68 | + * @param int $max Maximum number of records to load |
|
69 | 69 | * @return void |
70 | - */ |
|
71 | - function loadBox($max=5) |
|
72 | - { |
|
73 | - global $conf, $user, $langs, $db; |
|
70 | + */ |
|
71 | + function loadBox($max=5) |
|
72 | + { |
|
73 | + global $conf, $user, $langs, $db; |
|
74 | 74 | |
75 | - $this->max=$max; |
|
75 | + $this->max=$max; |
|
76 | 76 | |
77 | - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
|
77 | + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
|
78 | 78 | include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; |
79 | 79 | |
80 | 80 | $facturestatic = new FactureFournisseur($db); |
81 | 81 | $thirdpartytmp = new Fournisseur($db); |
82 | 82 | |
83 | - $this->info_box_head = array( |
|
84 | - 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierBills",$max) |
|
85 | - ); |
|
83 | + $this->info_box_head = array( |
|
84 | + 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierBills",$max) |
|
85 | + ); |
|
86 | 86 | |
87 | - if ($user->rights->fournisseur->facture->lire) |
|
88 | - { |
|
89 | - $sql = "SELECT s.nom as name, s.rowid as socid,"; |
|
87 | + if ($user->rights->fournisseur->facture->lire) |
|
88 | + { |
|
89 | + $sql = "SELECT s.nom as name, s.rowid as socid,"; |
|
90 | 90 | $sql.= " s.code_fournisseur,"; |
91 | 91 | $sql.= " s.logo,"; |
92 | - $sql.= " f.rowid as facid, f.ref, f.ref_supplier,"; |
|
92 | + $sql.= " f.rowid as facid, f.ref, f.ref_supplier,"; |
|
93 | 93 | $sql.= " f.total_ht,"; |
94 | 94 | $sql.= " f.total_tva,"; |
95 | 95 | $sql.= " f.total_ttc,"; |
96 | - $sql.= " f.paye, f.fk_statut,"; |
|
97 | - $sql.= ' f.datef as df,'; |
|
98 | - $sql.= ' f.datec as datec,'; |
|
99 | - $sql.= ' f.date_lim_reglement as datelimite, f.tms, f.type'; |
|
100 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
101 | - $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
102 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
103 | - $sql.= " WHERE f.fk_soc = s.rowid"; |
|
104 | - $sql.= " AND f.entity = ".$conf->entity; |
|
105 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
106 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
96 | + $sql.= " f.paye, f.fk_statut,"; |
|
97 | + $sql.= ' f.datef as df,'; |
|
98 | + $sql.= ' f.datec as datec,'; |
|
99 | + $sql.= ' f.date_lim_reglement as datelimite, f.tms, f.type'; |
|
100 | + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
101 | + $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
102 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
103 | + $sql.= " WHERE f.fk_soc = s.rowid"; |
|
104 | + $sql.= " AND f.entity = ".$conf->entity; |
|
105 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
106 | + if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
107 | 107 | if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
108 | 108 | else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; |
109 | - $sql.= $db->plimit($max, 0); |
|
109 | + $sql.= $db->plimit($max, 0); |
|
110 | 110 | |
111 | - $result = $db->query($sql); |
|
112 | - if ($result) |
|
113 | - { |
|
114 | - $num = $db->num_rows($result); |
|
111 | + $result = $db->query($sql); |
|
112 | + if ($result) |
|
113 | + { |
|
114 | + $num = $db->num_rows($result); |
|
115 | 115 | |
116 | - $line = 0; |
|
117 | - $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; |
|
116 | + $line = 0; |
|
117 | + $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; |
|
118 | 118 | |
119 | 119 | while ($line < $num) { |
120 | - $objp = $db->fetch_object($result); |
|
121 | - $datelimite=$db->jdate($objp->datelimite); |
|
122 | - $date=$db->jdate($objp->df); |
|
123 | - $datem=$db->jdate($objp->tms); |
|
120 | + $objp = $db->fetch_object($result); |
|
121 | + $datelimite=$db->jdate($objp->datelimite); |
|
122 | + $date=$db->jdate($objp->df); |
|
123 | + $datem=$db->jdate($objp->tms); |
|
124 | 124 | |
125 | 125 | $facturestatic->id = $objp->facid; |
126 | 126 | $facturestatic->ref = $objp->ref; |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; |
138 | 138 | $thirdpartytmp->logo = $objp->logo; |
139 | 139 | |
140 | - $late = ''; |
|
140 | + $late = ''; |
|
141 | 141 | |
142 | - if ($facturestatic->hasDelay()) { |
|
142 | + if ($facturestatic->hasDelay()) { |
|
143 | 143 | $late=img_warning(sprintf($l_due_date, dol_print_date($datelimite,'day'))); |
144 | 144 | } |
145 | 145 | |
@@ -206,17 +206,17 @@ discard block |
||
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
209 | - /** |
|
210 | - * Method to show box |
|
211 | - * |
|
212 | - * @param array $head Array with properties of box title |
|
213 | - * @param array $contents Array with properties of box lines |
|
214 | - * @param int $nooutput No print, only return string |
|
215 | - * @return string |
|
216 | - */ |
|
209 | + /** |
|
210 | + * Method to show box |
|
211 | + * |
|
212 | + * @param array $head Array with properties of box title |
|
213 | + * @param array $contents Array with properties of box lines |
|
214 | + * @param int $nooutput No print, only return string |
|
215 | + * @return string |
|
216 | + */ |
|
217 | 217 | function showBox($head = null, $contents = null, $nooutput=0) |
218 | 218 | { |
219 | - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
220 | - } |
|
219 | + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
220 | + } |
|
221 | 221 | } |
222 | 222 |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class box_factures_fourn extends ModeleBoxes |
33 | 33 | { |
34 | - var $boxcode="lastsupplierbills"; |
|
35 | - var $boximg="object_bill"; |
|
36 | - var $boxlabel="BoxLastSupplierBills"; |
|
37 | - var $depends = array("facture","fournisseur"); |
|
34 | + var $boxcode = "lastsupplierbills"; |
|
35 | + var $boximg = "object_bill"; |
|
36 | + var $boxlabel = "BoxLastSupplierBills"; |
|
37 | + var $depends = array("facture", "fournisseur"); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @var DoliDB Database handler. |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | * @param DoliDB $db Database handler |
54 | 54 | * @param string $param More parameters |
55 | 55 | */ |
56 | - function __construct($db,$param) |
|
56 | + function __construct($db, $param) |
|
57 | 57 | { |
58 | 58 | global $user; |
59 | 59 | |
60 | - $this->db=$db; |
|
60 | + $this->db = $db; |
|
61 | 61 | |
62 | - $this->hidden=! ($user->rights->fournisseur->facture->lire); |
|
62 | + $this->hidden = !($user->rights->fournisseur->facture->lire); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | * @param int $max Maximum number of records to load |
69 | 69 | * @return void |
70 | 70 | */ |
71 | - function loadBox($max=5) |
|
71 | + function loadBox($max = 5) |
|
72 | 72 | { |
73 | 73 | global $conf, $user, $langs, $db; |
74 | 74 | |
75 | - $this->max=$max; |
|
75 | + $this->max = $max; |
|
76 | 76 | |
77 | 77 | include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
78 | 78 | include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; |
@@ -81,32 +81,32 @@ discard block |
||
81 | 81 | $thirdpartytmp = new Fournisseur($db); |
82 | 82 | |
83 | 83 | $this->info_box_head = array( |
84 | - 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?"":"Modified")."SupplierBills",$max) |
|
84 | + 'text' => $langs->trans("BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified")."SupplierBills", $max) |
|
85 | 85 | ); |
86 | 86 | |
87 | 87 | if ($user->rights->fournisseur->facture->lire) |
88 | 88 | { |
89 | 89 | $sql = "SELECT s.nom as name, s.rowid as socid,"; |
90 | - $sql.= " s.code_fournisseur,"; |
|
91 | - $sql.= " s.logo,"; |
|
92 | - $sql.= " f.rowid as facid, f.ref, f.ref_supplier,"; |
|
93 | - $sql.= " f.total_ht,"; |
|
94 | - $sql.= " f.total_tva,"; |
|
95 | - $sql.= " f.total_ttc,"; |
|
96 | - $sql.= " f.paye, f.fk_statut,"; |
|
97 | - $sql.= ' f.datef as df,'; |
|
98 | - $sql.= ' f.datec as datec,'; |
|
99 | - $sql.= ' f.date_lim_reglement as datelimite, f.tms, f.type'; |
|
100 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
101 | - $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
102 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
103 | - $sql.= " WHERE f.fk_soc = s.rowid"; |
|
104 | - $sql.= " AND f.entity = ".$conf->entity; |
|
105 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
106 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
107 | - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
|
108 | - else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; |
|
109 | - $sql.= $db->plimit($max, 0); |
|
90 | + $sql .= " s.code_fournisseur,"; |
|
91 | + $sql .= " s.logo,"; |
|
92 | + $sql .= " f.rowid as facid, f.ref, f.ref_supplier,"; |
|
93 | + $sql .= " f.total_ht,"; |
|
94 | + $sql .= " f.total_tva,"; |
|
95 | + $sql .= " f.total_ttc,"; |
|
96 | + $sql .= " f.paye, f.fk_statut,"; |
|
97 | + $sql .= ' f.datef as df,'; |
|
98 | + $sql .= ' f.datec as datec,'; |
|
99 | + $sql .= ' f.date_lim_reglement as datelimite, f.tms, f.type'; |
|
100 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
101 | + $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
102 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
103 | + $sql .= " WHERE f.fk_soc = s.rowid"; |
|
104 | + $sql .= " AND f.entity = ".$conf->entity; |
|
105 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
106 | + if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id; |
|
107 | + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .= " ORDER BY f.datef DESC, f.ref DESC "; |
|
108 | + else $sql .= " ORDER BY f.tms DESC, f.ref DESC "; |
|
109 | + $sql .= $db->plimit($max, 0); |
|
110 | 110 | |
111 | 111 | $result = $db->query($sql); |
112 | 112 | if ($result) |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | $num = $db->num_rows($result); |
115 | 115 | |
116 | 116 | $line = 0; |
117 | - $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; |
|
117 | + $l_due_date = $langs->trans('Late').' ('.$langs->trans('DateDue').': %s)'; |
|
118 | 118 | |
119 | 119 | while ($line < $num) { |
120 | 120 | $objp = $db->fetch_object($result); |
121 | - $datelimite=$db->jdate($objp->datelimite); |
|
122 | - $date=$db->jdate($objp->df); |
|
123 | - $datem=$db->jdate($objp->tms); |
|
121 | + $datelimite = $db->jdate($objp->datelimite); |
|
122 | + $date = $db->jdate($objp->df); |
|
123 | + $datem = $db->jdate($objp->tms); |
|
124 | 124 | |
125 | 125 | $facturestatic->id = $objp->facid; |
126 | 126 | $facturestatic->ref = $objp->ref; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $late = ''; |
141 | 141 | |
142 | 142 | if ($facturestatic->hasDelay()) { |
143 | - $late=img_warning(sprintf($l_due_date, dol_print_date($datelimite,'day'))); |
|
143 | + $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | $this->info_box_contents[$line][] = array( |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $this->info_box_contents[$line][] = array( |
154 | 154 | 'td' => 'class="tdoverflowmax50"', |
155 | 155 | 'text' => $objp->ref_supplier, |
156 | - 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref?$objp->ref:$objp->facid).'<br>'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, |
|
156 | + 'tooltip' => $langs->trans('SupplierInvoice').': '.($objp->ref ? $objp->ref : $objp->facid).'<br>'.$langs->trans('RefSupplier').': '.$objp->ref_supplier, |
|
157 | 157 | 'url' => DOL_URL_ROOT."/fourn/facture/card.php?facid=".$objp->facid, |
158 | 158 | ); |
159 | 159 | |
@@ -170,21 +170,21 @@ discard block |
||
170 | 170 | |
171 | 171 | $this->info_box_contents[$line][] = array( |
172 | 172 | 'td' => 'class="right"', |
173 | - 'text' => dol_print_date($date,'day'), |
|
173 | + 'text' => dol_print_date($date, 'day'), |
|
174 | 174 | ); |
175 | 175 | |
176 | 176 | $fac = new FactureFournisseur($db); |
177 | 177 | $fac->fetch($objp->facid); |
178 | - $alreadypaid=$fac->getSommePaiement(); |
|
178 | + $alreadypaid = $fac->getSommePaiement(); |
|
179 | 179 | $this->info_box_contents[$line][] = array( |
180 | 180 | 'td' => 'align="right" width="18"', |
181 | - 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$alreadypaid,$objp->type), |
|
181 | + 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type), |
|
182 | 182 | ); |
183 | 183 | |
184 | 184 | $line++; |
185 | 185 | } |
186 | 186 | |
187 | - if ($num==0) |
|
187 | + if ($num == 0) |
|
188 | 188 | $this->info_box_contents[$line][0] = array( |
189 | 189 | 'td' => 'align="center"', |
190 | 190 | 'text'=>$langs->trans("NoModifiedSupplierBills"), |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @param int $nooutput No print, only return string |
215 | 215 | * @return string |
216 | 216 | */ |
217 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
217 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
218 | 218 | { |
219 | 219 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
220 | 220 | } |
@@ -99,13 +99,22 @@ discard block |
||
99 | 99 | $sql.= ' f.date_lim_reglement as datelimite, f.tms, f.type'; |
100 | 100 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
101 | 101 | $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; |
102 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
102 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
103 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
104 | + } |
|
103 | 105 | $sql.= " WHERE f.fk_soc = s.rowid"; |
104 | 106 | $sql.= " AND f.entity = ".$conf->entity; |
105 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
106 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
107 | - if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
|
108 | - else $sql.= " ORDER BY f.tms DESC, f.ref DESC "; |
|
107 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
108 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
109 | + } |
|
110 | + if($user->societe_id) { |
|
111 | + $sql.= " AND s.rowid = ".$user->societe_id; |
|
112 | + } |
|
113 | + if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) { |
|
114 | + $sql.= " ORDER BY f.datef DESC, f.ref DESC "; |
|
115 | + } else { |
|
116 | + $sql.= " ORDER BY f.tms DESC, f.ref DESC "; |
|
117 | + } |
|
109 | 118 | $sql.= $db->plimit($max, 0); |
110 | 119 | |
111 | 120 | $result = $db->query($sql); |
@@ -184,11 +193,12 @@ discard block |
||
184 | 193 | $line++; |
185 | 194 | } |
186 | 195 | |
187 | - if ($num==0) |
|
188 | - $this->info_box_contents[$line][0] = array( |
|
196 | + if ($num==0) { |
|
197 | + $this->info_box_contents[$line][0] = array( |
|
189 | 198 | 'td' => 'align="center"', |
190 | 199 | 'text'=>$langs->trans("NoModifiedSupplierBills"), |
191 | 200 | ); |
201 | + } |
|
192 | 202 | |
193 | 203 | $db->free($result); |
194 | 204 | } else { |
@@ -33,145 +33,145 @@ |
||
33 | 33 | */ |
34 | 34 | class box_goodcustomers extends ModeleBoxes |
35 | 35 | { |
36 | - var $boxcode="goodcustomers"; |
|
37 | - var $boximg="object_company"; |
|
38 | - var $boxlabel="BoxGoodCustomers"; |
|
39 | - var $depends = array("societe"); |
|
36 | + var $boxcode="goodcustomers"; |
|
37 | + var $boximg="object_company"; |
|
38 | + var $boxlabel="BoxGoodCustomers"; |
|
39 | + var $depends = array("societe"); |
|
40 | 40 | |
41 | - /** |
|
41 | + /** |
|
42 | 42 | * @var DoliDB Database handler. |
43 | 43 | */ |
44 | 44 | public $db; |
45 | 45 | |
46 | - var $enabled = 1; |
|
46 | + var $enabled = 1; |
|
47 | 47 | |
48 | - var $info_box_head = array(); |
|
49 | - var $info_box_contents = array(); |
|
48 | + var $info_box_head = array(); |
|
49 | + var $info_box_contents = array(); |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * Constructor |
|
54 | - * |
|
55 | - * @param DoliDB $db Database handler |
|
52 | + /** |
|
53 | + * Constructor |
|
54 | + * |
|
55 | + * @param DoliDB $db Database handler |
|
56 | 56 | * @param string $param More parameters |
57 | - */ |
|
58 | - function __construct($db,$param='') |
|
59 | - { |
|
60 | - global $conf, $user; |
|
57 | + */ |
|
58 | + function __construct($db,$param='') |
|
59 | + { |
|
60 | + global $conf, $user; |
|
61 | 61 | |
62 | - $this->db = $db; |
|
62 | + $this->db = $db; |
|
63 | 63 | |
64 | - // disable box for such cases |
|
65 | - if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option |
|
66 | - if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database |
|
64 | + // disable box for such cases |
|
65 | + if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option |
|
66 | + if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database |
|
67 | 67 | |
68 | - $this->hidden = ! ($user->rights->societe->lire); |
|
69 | - } |
|
68 | + $this->hidden = ! ($user->rights->societe->lire); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
71 | + /** |
|
72 | 72 | * Load data for box to show them later |
73 | 73 | * |
74 | 74 | * @param int $max Maximum number of records to load |
75 | 75 | * @return void |
76 | - */ |
|
77 | - function loadBox($max=5) |
|
78 | - { |
|
79 | - global $user, $langs, $db, $conf; |
|
80 | - $langs->load("boxes"); |
|
76 | + */ |
|
77 | + function loadBox($max=5) |
|
78 | + { |
|
79 | + global $user, $langs, $db, $conf; |
|
80 | + $langs->load("boxes"); |
|
81 | 81 | |
82 | - $this->max=$max; |
|
82 | + $this->max=$max; |
|
83 | 83 | |
84 | 84 | include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
85 | 85 | $thirdpartystatic=new Societe($db); |
86 | 86 | |
87 | 87 | $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers",$max)); |
88 | 88 | |
89 | - if ($user->rights->societe->lire) |
|
90 | - { |
|
91 | - |
|
92 | - $sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,"; |
|
93 | - $sql.= " count(*) as nbfact, sum(". $db->ifsql('f.paye=1','1','0').") as nbfactpaye"; |
|
94 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; |
|
95 | - $sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; |
|
96 | - $sql.= ' AND s.rowid = f.fk_soc'; |
|
97 | - $sql.= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; |
|
98 | - $sql.= $db->order("nbfact","DESC"); |
|
99 | - $sql.= $db->plimit($max,0); |
|
100 | - |
|
101 | - dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); |
|
102 | - $result = $db->query($sql); |
|
103 | - if ($result) |
|
104 | - { |
|
105 | - $num = $db->num_rows($result); |
|
106 | - |
|
107 | - $line = 0; |
|
108 | - while ($line < $num) |
|
109 | - { |
|
110 | - $objp = $db->fetch_object($result); |
|
111 | - $datem=$db->jdate($objp->tms); |
|
112 | - $thirdpartystatic->id = $objp->rowid; |
|
113 | - $thirdpartystatic->name = $objp->name; |
|
114 | - $thirdpartystatic->code_client = $objp->code_client; |
|
115 | - $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; |
|
116 | - $thirdpartystatic->client = $objp->client; |
|
117 | - $thirdpartystatic->fournisseur = $objp->fournisseur; |
|
118 | - $thirdpartystatic->logo = $objp->logo; |
|
119 | - $nbfact = $objp->nbfact; |
|
120 | - $nbimpaye = $objp->nbfact - $objp->nbfactpaye; |
|
121 | - |
|
122 | - $this->info_box_contents[$line][] = array( |
|
123 | - 'td' => '', |
|
124 | - 'text' => $thirdpartystatic->getNomUrl(1), |
|
125 | - 'asis' => 1, |
|
126 | - ); |
|
127 | - |
|
128 | - $this->info_box_contents[$line][] = array( |
|
129 | - 'td' => 'class="right"', |
|
130 | - 'text' => dol_print_date($datem, "day") |
|
131 | - ); |
|
132 | - |
|
133 | - $this->info_box_contents[$line][] = array( |
|
134 | - 'td' => 'class="right"', |
|
135 | - 'text' => $nbfact.( $nbimpaye != 0 ? ' ('.$nbimpaye.')':'') |
|
136 | - ); |
|
137 | - |
|
138 | - $this->info_box_contents[$line][] = array( |
|
139 | - 'td' => 'align="right" width="18"', |
|
140 | - 'text' => $thirdpartystatic->LibStatut($objp->status,3) |
|
141 | - ); |
|
142 | - |
|
143 | - $line++; |
|
144 | - } |
|
145 | - |
|
146 | - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedCustomers")); |
|
147 | - |
|
148 | - $db->free($result); |
|
149 | - } |
|
150 | - else { |
|
151 | - $this->info_box_contents[0][0] = array( 'td' => '', |
|
152 | - 'maxlength'=>500, |
|
153 | - 'text' => ($db->error().' sql='.$sql)); |
|
154 | - } |
|
155 | - } |
|
156 | - else { |
|
157 | - $this->info_box_contents[0][0] = array( |
|
158 | - 'td' => 'align="left" class="nohover opacitymedium"', |
|
159 | - 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
160 | - ); |
|
161 | - } |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * Method to show box |
|
166 | - * |
|
167 | - * @param array $head Array with properties of box title |
|
168 | - * @param array $contents Array with properties of box lines |
|
169 | - * @param int $nooutput No print, only return string |
|
170 | - * @return string |
|
171 | - */ |
|
89 | + if ($user->rights->societe->lire) |
|
90 | + { |
|
91 | + |
|
92 | + $sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,"; |
|
93 | + $sql.= " count(*) as nbfact, sum(". $db->ifsql('f.paye=1','1','0').") as nbfactpaye"; |
|
94 | + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; |
|
95 | + $sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; |
|
96 | + $sql.= ' AND s.rowid = f.fk_soc'; |
|
97 | + $sql.= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; |
|
98 | + $sql.= $db->order("nbfact","DESC"); |
|
99 | + $sql.= $db->plimit($max,0); |
|
100 | + |
|
101 | + dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); |
|
102 | + $result = $db->query($sql); |
|
103 | + if ($result) |
|
104 | + { |
|
105 | + $num = $db->num_rows($result); |
|
106 | + |
|
107 | + $line = 0; |
|
108 | + while ($line < $num) |
|
109 | + { |
|
110 | + $objp = $db->fetch_object($result); |
|
111 | + $datem=$db->jdate($objp->tms); |
|
112 | + $thirdpartystatic->id = $objp->rowid; |
|
113 | + $thirdpartystatic->name = $objp->name; |
|
114 | + $thirdpartystatic->code_client = $objp->code_client; |
|
115 | + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; |
|
116 | + $thirdpartystatic->client = $objp->client; |
|
117 | + $thirdpartystatic->fournisseur = $objp->fournisseur; |
|
118 | + $thirdpartystatic->logo = $objp->logo; |
|
119 | + $nbfact = $objp->nbfact; |
|
120 | + $nbimpaye = $objp->nbfact - $objp->nbfactpaye; |
|
121 | + |
|
122 | + $this->info_box_contents[$line][] = array( |
|
123 | + 'td' => '', |
|
124 | + 'text' => $thirdpartystatic->getNomUrl(1), |
|
125 | + 'asis' => 1, |
|
126 | + ); |
|
127 | + |
|
128 | + $this->info_box_contents[$line][] = array( |
|
129 | + 'td' => 'class="right"', |
|
130 | + 'text' => dol_print_date($datem, "day") |
|
131 | + ); |
|
132 | + |
|
133 | + $this->info_box_contents[$line][] = array( |
|
134 | + 'td' => 'class="right"', |
|
135 | + 'text' => $nbfact.( $nbimpaye != 0 ? ' ('.$nbimpaye.')':'') |
|
136 | + ); |
|
137 | + |
|
138 | + $this->info_box_contents[$line][] = array( |
|
139 | + 'td' => 'align="right" width="18"', |
|
140 | + 'text' => $thirdpartystatic->LibStatut($objp->status,3) |
|
141 | + ); |
|
142 | + |
|
143 | + $line++; |
|
144 | + } |
|
145 | + |
|
146 | + if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedCustomers")); |
|
147 | + |
|
148 | + $db->free($result); |
|
149 | + } |
|
150 | + else { |
|
151 | + $this->info_box_contents[0][0] = array( 'td' => '', |
|
152 | + 'maxlength'=>500, |
|
153 | + 'text' => ($db->error().' sql='.$sql)); |
|
154 | + } |
|
155 | + } |
|
156 | + else { |
|
157 | + $this->info_box_contents[0][0] = array( |
|
158 | + 'td' => 'align="left" class="nohover opacitymedium"', |
|
159 | + 'text' => $langs->trans("ReadPermissionNotAllowed") |
|
160 | + ); |
|
161 | + } |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * Method to show box |
|
166 | + * |
|
167 | + * @param array $head Array with properties of box title |
|
168 | + * @param array $contents Array with properties of box lines |
|
169 | + * @param int $nooutput No print, only return string |
|
170 | + * @return string |
|
171 | + */ |
|
172 | 172 | function showBox($head = null, $contents = null, $nooutput=0) |
173 | 173 | { |
174 | - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
175 | - } |
|
174 | + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
175 | + } |
|
176 | 176 | } |
177 | 177 |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class box_goodcustomers extends ModeleBoxes |
35 | 35 | { |
36 | - var $boxcode="goodcustomers"; |
|
37 | - var $boximg="object_company"; |
|
38 | - var $boxlabel="BoxGoodCustomers"; |
|
36 | + var $boxcode = "goodcustomers"; |
|
37 | + var $boximg = "object_company"; |
|
38 | + var $boxlabel = "BoxGoodCustomers"; |
|
39 | 39 | var $depends = array("societe"); |
40 | 40 | |
41 | 41 | /** |
@@ -55,17 +55,17 @@ discard block |
||
55 | 55 | * @param DoliDB $db Database handler |
56 | 56 | * @param string $param More parameters |
57 | 57 | */ |
58 | - function __construct($db,$param='') |
|
58 | + function __construct($db, $param = '') |
|
59 | 59 | { |
60 | 60 | global $conf, $user; |
61 | 61 | |
62 | 62 | $this->db = $db; |
63 | 63 | |
64 | 64 | // disable box for such cases |
65 | - if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option |
|
66 | - if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database |
|
65 | + if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled = 0; // disabled by this option |
|
66 | + if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled = 0; // not enabled by default. Very slow on large database |
|
67 | 67 | |
68 | - $this->hidden = ! ($user->rights->societe->lire); |
|
68 | + $this->hidden = !($user->rights->societe->lire); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -74,29 +74,29 @@ discard block |
||
74 | 74 | * @param int $max Maximum number of records to load |
75 | 75 | * @return void |
76 | 76 | */ |
77 | - function loadBox($max=5) |
|
77 | + function loadBox($max = 5) |
|
78 | 78 | { |
79 | 79 | global $user, $langs, $db, $conf; |
80 | 80 | $langs->load("boxes"); |
81 | 81 | |
82 | - $this->max=$max; |
|
82 | + $this->max = $max; |
|
83 | 83 | |
84 | 84 | include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
85 | - $thirdpartystatic=new Societe($db); |
|
85 | + $thirdpartystatic = new Societe($db); |
|
86 | 86 | |
87 | - $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers",$max)); |
|
87 | + $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max)); |
|
88 | 88 | |
89 | 89 | if ($user->rights->societe->lire) |
90 | 90 | { |
91 | 91 | |
92 | 92 | $sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,"; |
93 | - $sql.= " count(*) as nbfact, sum(". $db->ifsql('f.paye=1','1','0').") as nbfactpaye"; |
|
94 | - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; |
|
95 | - $sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; |
|
96 | - $sql.= ' AND s.rowid = f.fk_soc'; |
|
97 | - $sql.= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; |
|
98 | - $sql.= $db->order("nbfact","DESC"); |
|
99 | - $sql.= $db->plimit($max,0); |
|
93 | + $sql .= " count(*) as nbfact, sum(".$db->ifsql('f.paye=1', '1', '0').") as nbfactpaye"; |
|
94 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; |
|
95 | + $sql .= ' WHERE s.entity IN ('.getEntity('societe').')'; |
|
96 | + $sql .= ' AND s.rowid = f.fk_soc'; |
|
97 | + $sql .= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; |
|
98 | + $sql .= $db->order("nbfact", "DESC"); |
|
99 | + $sql .= $db->plimit($max, 0); |
|
100 | 100 | |
101 | 101 | dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); |
102 | 102 | $result = $db->query($sql); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | while ($line < $num) |
109 | 109 | { |
110 | 110 | $objp = $db->fetch_object($result); |
111 | - $datem=$db->jdate($objp->tms); |
|
111 | + $datem = $db->jdate($objp->tms); |
|
112 | 112 | $thirdpartystatic->id = $objp->rowid; |
113 | 113 | $thirdpartystatic->name = $objp->name; |
114 | 114 | $thirdpartystatic->code_client = $objp->code_client; |
@@ -132,23 +132,23 @@ discard block |
||
132 | 132 | |
133 | 133 | $this->info_box_contents[$line][] = array( |
134 | 134 | 'td' => 'class="right"', |
135 | - 'text' => $nbfact.( $nbimpaye != 0 ? ' ('.$nbimpaye.')':'') |
|
135 | + 'text' => $nbfact.($nbimpaye != 0 ? ' ('.$nbimpaye.')' : '') |
|
136 | 136 | ); |
137 | 137 | |
138 | 138 | $this->info_box_contents[$line][] = array( |
139 | 139 | 'td' => 'align="right" width="18"', |
140 | - 'text' => $thirdpartystatic->LibStatut($objp->status,3) |
|
140 | + 'text' => $thirdpartystatic->LibStatut($objp->status, 3) |
|
141 | 141 | ); |
142 | 142 | |
143 | 143 | $line++; |
144 | 144 | } |
145 | 145 | |
146 | - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedCustomers")); |
|
146 | + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text'=>$langs->trans("NoRecordedCustomers")); |
|
147 | 147 | |
148 | 148 | $db->free($result); |
149 | 149 | } |
150 | 150 | else { |
151 | - $this->info_box_contents[0][0] = array( 'td' => '', |
|
151 | + $this->info_box_contents[0][0] = array('td' => '', |
|
152 | 152 | 'maxlength'=>500, |
153 | 153 | 'text' => ($db->error().' sql='.$sql)); |
154 | 154 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param int $nooutput No print, only return string |
170 | 170 | * @return string |
171 | 171 | */ |
172 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
172 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
173 | 173 | { |
174 | 174 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
175 | 175 | } |
@@ -62,8 +62,14 @@ discard block |
||
62 | 62 | $this->db = $db; |
63 | 63 | |
64 | 64 | // disable box for such cases |
65 | - if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option |
|
66 | - if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database |
|
65 | + if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { |
|
66 | + $this->enabled=0; |
|
67 | + } |
|
68 | + // disabled by this option |
|
69 | + if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) { |
|
70 | + $this->enabled=0; |
|
71 | + } |
|
72 | + // not enabled by default. Very slow on large database |
|
67 | 73 | |
68 | 74 | $this->hidden = ! ($user->rights->societe->lire); |
69 | 75 | } |
@@ -143,17 +149,17 @@ discard block |
||
143 | 149 | $line++; |
144 | 150 | } |
145 | 151 | |
146 | - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedCustomers")); |
|
152 | + if ($num==0) { |
|
153 | + $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedCustomers")); |
|
154 | + } |
|
147 | 155 | |
148 | 156 | $db->free($result); |
149 | - } |
|
150 | - else { |
|
157 | + } else { |
|
151 | 158 | $this->info_box_contents[0][0] = array( 'td' => '', |
152 | 159 | 'maxlength'=>500, |
153 | 160 | 'text' => ($db->error().' sql='.$sql)); |
154 | 161 | } |
155 | - } |
|
156 | - else { |
|
162 | + } else { |
|
157 | 163 | $this->info_box_contents[0][0] = array( |
158 | 164 | 'td' => 'align="left" class="nohover opacitymedium"', |
159 | 165 | 'text' => $langs->trans("ReadPermissionNotAllowed") |
@@ -32,218 +32,218 @@ |
||
32 | 32 | */ |
33 | 33 | class box_services_contracts extends ModeleBoxes |
34 | 34 | { |
35 | - var $boxcode="lastproductsincontract"; |
|
36 | - var $boximg="object_product"; |
|
37 | - var $boxlabel="BoxLastProductsInContract"; |
|
38 | - var $depends = array("service","contrat"); |
|
35 | + var $boxcode="lastproductsincontract"; |
|
36 | + var $boximg="object_product"; |
|
37 | + var $boxlabel="BoxLastProductsInContract"; |
|
38 | + var $depends = array("service","contrat"); |
|
39 | 39 | |
40 | - /** |
|
40 | + /** |
|
41 | 41 | * @var DoliDB Database handler. |
42 | 42 | */ |
43 | 43 | public $db; |
44 | 44 | |
45 | - var $param; |
|
45 | + var $param; |
|
46 | 46 | |
47 | - var $info_box_head = array(); |
|
48 | - var $info_box_contents = array(); |
|
47 | + var $info_box_head = array(); |
|
48 | + var $info_box_contents = array(); |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * Constructor |
|
53 | - * |
|
54 | - * @param DoliDB $db Database handler |
|
55 | - * @param string $param More parameters |
|
56 | - */ |
|
57 | - function __construct($db,$param) |
|
58 | - { |
|
59 | - global $user; |
|
51 | + /** |
|
52 | + * Constructor |
|
53 | + * |
|
54 | + * @param DoliDB $db Database handler |
|
55 | + * @param string $param More parameters |
|
56 | + */ |
|
57 | + function __construct($db,$param) |
|
58 | + { |
|
59 | + global $user; |
|
60 | 60 | |
61 | - $this->db=$db; |
|
61 | + $this->db=$db; |
|
62 | 62 | |
63 | - $this->hidden=! ($user->rights->service->lire && $user->rights->contrat->lire); |
|
64 | - } |
|
63 | + $this->hidden=! ($user->rights->service->lire && $user->rights->contrat->lire); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Load data into info_box_contents array to show array later. |
|
68 | - * |
|
69 | - * @param int $max Maximum number of records to load |
|
66 | + /** |
|
67 | + * Load data into info_box_contents array to show array later. |
|
68 | + * |
|
69 | + * @param int $max Maximum number of records to load |
|
70 | 70 | * @return void |
71 | - */ |
|
72 | - function loadBox($max=5) |
|
73 | - { |
|
74 | - global $user, $langs, $db, $conf; |
|
75 | - |
|
76 | - $this->max=$max; |
|
77 | - |
|
78 | - include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
|
79 | - |
|
80 | - $form = new Form($db); |
|
81 | - |
|
82 | - $this->info_box_head = array('text' => $langs->trans("BoxLastProductsInContract",$max)); |
|
83 | - |
|
84 | - if ($user->rights->service->lire && $user->rights->contrat->lire) |
|
85 | - { |
|
86 | - $contractstatic=new Contrat($db); |
|
87 | - $contratlignestatic=new ContratLigne($db); |
|
88 | - $thirdpartytmp = new Societe($db); |
|
89 | - $productstatic = new Product($db); |
|
90 | - |
|
91 | - $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; |
|
92 | - $sql.= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; |
|
93 | - $sql.= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,"; |
|
94 | - $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity"; |
|
95 | - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s"; |
|
96 | - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; |
|
97 | - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; |
|
98 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; |
|
99 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
100 | - $sql.= ")"; |
|
101 | - $sql.= " WHERE c.entity = ".$conf->entity; |
|
102 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
103 | - $sql.= $db->order("c.tms","DESC"); |
|
104 | - $sql.= $db->plimit($max, 0); |
|
105 | - |
|
106 | - $result = $db->query($sql); |
|
107 | - if ($result) |
|
108 | - { |
|
109 | - $num = $db->num_rows($result); |
|
110 | - $now=dol_now(); |
|
111 | - |
|
112 | - $i = 0; |
|
113 | - |
|
114 | - while ($i < $num) |
|
115 | - { |
|
116 | - $objp = $db->fetch_object($result); |
|
117 | - $datem=$db->jdate($objp->datem); |
|
118 | - |
|
119 | - $contratlignestatic->id=$objp->cdid; |
|
120 | - $contratlignestatic->fk_contrat=$objp->rowid; |
|
121 | - $contratlignestatic->label=$objp->label; |
|
122 | - $contratlignestatic->description=$objp->description; |
|
123 | - $contratlignestatic->type=$objp->type; |
|
124 | - $contratlignestatic->product_id=$objp->product_id; |
|
125 | - $contratlignestatic->product_ref=$objp->product_ref; |
|
71 | + */ |
|
72 | + function loadBox($max=5) |
|
73 | + { |
|
74 | + global $user, $langs, $db, $conf; |
|
75 | + |
|
76 | + $this->max=$max; |
|
77 | + |
|
78 | + include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
|
79 | + |
|
80 | + $form = new Form($db); |
|
81 | + |
|
82 | + $this->info_box_head = array('text' => $langs->trans("BoxLastProductsInContract",$max)); |
|
83 | + |
|
84 | + if ($user->rights->service->lire && $user->rights->contrat->lire) |
|
85 | + { |
|
86 | + $contractstatic=new Contrat($db); |
|
87 | + $contratlignestatic=new ContratLigne($db); |
|
88 | + $thirdpartytmp = new Societe($db); |
|
89 | + $productstatic = new Product($db); |
|
90 | + |
|
91 | + $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; |
|
92 | + $sql.= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; |
|
93 | + $sql.= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,"; |
|
94 | + $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity"; |
|
95 | + $sql.= " FROM (".MAIN_DB_PREFIX."societe as s"; |
|
96 | + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; |
|
97 | + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; |
|
98 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; |
|
99 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
100 | + $sql.= ")"; |
|
101 | + $sql.= " WHERE c.entity = ".$conf->entity; |
|
102 | + if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
103 | + $sql.= $db->order("c.tms","DESC"); |
|
104 | + $sql.= $db->plimit($max, 0); |
|
105 | + |
|
106 | + $result = $db->query($sql); |
|
107 | + if ($result) |
|
108 | + { |
|
109 | + $num = $db->num_rows($result); |
|
110 | + $now=dol_now(); |
|
111 | + |
|
112 | + $i = 0; |
|
113 | + |
|
114 | + while ($i < $num) |
|
115 | + { |
|
116 | + $objp = $db->fetch_object($result); |
|
117 | + $datem=$db->jdate($objp->datem); |
|
118 | + |
|
119 | + $contratlignestatic->id=$objp->cdid; |
|
120 | + $contratlignestatic->fk_contrat=$objp->rowid; |
|
121 | + $contratlignestatic->label=$objp->label; |
|
122 | + $contratlignestatic->description=$objp->description; |
|
123 | + $contratlignestatic->type=$objp->type; |
|
124 | + $contratlignestatic->product_id=$objp->product_id; |
|
125 | + $contratlignestatic->product_ref=$objp->product_ref; |
|
126 | 126 | |
127 | 127 | $contractstatic->statut=$objp->contract_status; |
128 | - $contractstatic->id=$objp->rowid; |
|
129 | - $contractstatic->ref=$objp->ref; |
|
130 | - $contractstatic->ref_customer=$objp->ref_customer; |
|
131 | - $contractstatic->ref_supplier=$objp->ref_supplier; |
|
132 | - |
|
133 | - $thirdpartytmp->name = $objp->name; |
|
134 | - $thirdpartytmp->id = $objp->socid; |
|
135 | - $thirdpartytmp->email = $objp->email; |
|
136 | - $thirdpartytmp->client = $objp->client; |
|
137 | - $thirdpartytmp->fournisseur = $objp->fournisseur; |
|
138 | - $thirdpartytmp->code_client = $objp->code_client; |
|
139 | - $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; |
|
140 | - $thirdpartytmp->code_compta = $objp->code_compta; |
|
141 | - $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; |
|
142 | - |
|
143 | - // Multilangs |
|
144 | - if (! empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) // if option multilang is on |
|
145 | - { |
|
146 | - $sqld = "SELECT label"; |
|
147 | - $sqld.= " FROM ".MAIN_DB_PREFIX."product_lang"; |
|
148 | - $sqld.= " WHERE fk_product=".$objp->product_id; |
|
149 | - $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; |
|
150 | - $sqld.= " LIMIT 1"; |
|
151 | - |
|
152 | - $resultd = $db->query($sqld); |
|
153 | - if ($resultd) |
|
154 | - { |
|
155 | - $objtp = $db->fetch_object($resultd); |
|
156 | - if ($objtp->label != '') $contratlignestatic->label = $objtp->label; |
|
157 | - } |
|
158 | - } |
|
159 | - |
|
160 | - // Label |
|
161 | - if ($objp->product_id > 0) |
|
162 | - { |
|
163 | - $productstatic->id=$objp->product_id; |
|
164 | - $productstatic->type=$objp->ptype; |
|
165 | - $productstatic->ref=$objp->product_ref; |
|
166 | - $productstatic->entity=$objp->pentity; |
|
167 | - $productstatic->label=$objp->plabel; |
|
168 | - $text = $productstatic->getNomUrl(1,'',20); |
|
169 | - if ($objp->plabel) |
|
170 | - { |
|
171 | - $text .= ' - '; |
|
172 | - //$productstatic->ref=$objp->label; |
|
173 | - //$text .= $productstatic->getNomUrl(0,'',16); |
|
174 | - $text .= $objp->plabel; |
|
175 | - } |
|
176 | - $description = $objp->description; |
|
177 | - |
|
178 | - // Add description in form |
|
179 | - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) |
|
180 | - { |
|
181 | - //$text .= (! empty($objp->description) && $objp->description!=$objp->plabel)?'<br>'.dol_htmlentitiesbr($objp->description):''; |
|
182 | - $description = ''; // Already added into main visible desc |
|
183 | - } |
|
184 | - |
|
185 | - $s = $form->textwithtooltip($text,$description,3,'','',$cursorline,0,(!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); |
|
186 | - } |
|
187 | - else |
|
188 | - { |
|
189 | - $s = img_object($langs->trans("ShowProductOrService"), ($objp->product_type ? 'service' : 'product')).' '.dol_htmlentitiesbr($objp->description); |
|
190 | - } |
|
191 | - |
|
192 | - |
|
193 | - $this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', |
|
128 | + $contractstatic->id=$objp->rowid; |
|
129 | + $contractstatic->ref=$objp->ref; |
|
130 | + $contractstatic->ref_customer=$objp->ref_customer; |
|
131 | + $contractstatic->ref_supplier=$objp->ref_supplier; |
|
132 | + |
|
133 | + $thirdpartytmp->name = $objp->name; |
|
134 | + $thirdpartytmp->id = $objp->socid; |
|
135 | + $thirdpartytmp->email = $objp->email; |
|
136 | + $thirdpartytmp->client = $objp->client; |
|
137 | + $thirdpartytmp->fournisseur = $objp->fournisseur; |
|
138 | + $thirdpartytmp->code_client = $objp->code_client; |
|
139 | + $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; |
|
140 | + $thirdpartytmp->code_compta = $objp->code_compta; |
|
141 | + $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; |
|
142 | + |
|
143 | + // Multilangs |
|
144 | + if (! empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) // if option multilang is on |
|
145 | + { |
|
146 | + $sqld = "SELECT label"; |
|
147 | + $sqld.= " FROM ".MAIN_DB_PREFIX."product_lang"; |
|
148 | + $sqld.= " WHERE fk_product=".$objp->product_id; |
|
149 | + $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; |
|
150 | + $sqld.= " LIMIT 1"; |
|
151 | + |
|
152 | + $resultd = $db->query($sqld); |
|
153 | + if ($resultd) |
|
154 | + { |
|
155 | + $objtp = $db->fetch_object($resultd); |
|
156 | + if ($objtp->label != '') $contratlignestatic->label = $objtp->label; |
|
157 | + } |
|
158 | + } |
|
159 | + |
|
160 | + // Label |
|
161 | + if ($objp->product_id > 0) |
|
162 | + { |
|
163 | + $productstatic->id=$objp->product_id; |
|
164 | + $productstatic->type=$objp->ptype; |
|
165 | + $productstatic->ref=$objp->product_ref; |
|
166 | + $productstatic->entity=$objp->pentity; |
|
167 | + $productstatic->label=$objp->plabel; |
|
168 | + $text = $productstatic->getNomUrl(1,'',20); |
|
169 | + if ($objp->plabel) |
|
170 | + { |
|
171 | + $text .= ' - '; |
|
172 | + //$productstatic->ref=$objp->label; |
|
173 | + //$text .= $productstatic->getNomUrl(0,'',16); |
|
174 | + $text .= $objp->plabel; |
|
175 | + } |
|
176 | + $description = $objp->description; |
|
177 | + |
|
178 | + // Add description in form |
|
179 | + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) |
|
180 | + { |
|
181 | + //$text .= (! empty($objp->description) && $objp->description!=$objp->plabel)?'<br>'.dol_htmlentitiesbr($objp->description):''; |
|
182 | + $description = ''; // Already added into main visible desc |
|
183 | + } |
|
184 | + |
|
185 | + $s = $form->textwithtooltip($text,$description,3,'','',$cursorline,0,(!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); |
|
186 | + } |
|
187 | + else |
|
188 | + { |
|
189 | + $s = img_object($langs->trans("ShowProductOrService"), ($objp->product_type ? 'service' : 'product')).' '.dol_htmlentitiesbr($objp->description); |
|
190 | + } |
|
191 | + |
|
192 | + |
|
193 | + $this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', |
|
194 | 194 | 'text' => $s, |
195 | - 'asis' => 1 |
|
195 | + 'asis' => 1 |
|
196 | 196 | ); |
197 | 197 | |
198 | - $this->info_box_contents[$i][] = array('td' => '', |
|
198 | + $this->info_box_contents[$i][] = array('td' => '', |
|
199 | 199 | 'text' => $contractstatic->getNomUrl(1), |
200 | - 'asis' => 1 |
|
200 | + 'asis' => 1 |
|
201 | 201 | ); |
202 | 202 | |
203 | - $this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', |
|
203 | + $this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', |
|
204 | 204 | 'text' => $thirdpartytmp->getNomUrl(1), |
205 | - 'asis' => 1 |
|
205 | + 'asis' => 1 |
|
206 | 206 | ); |
207 | 207 | |
208 | - $this->info_box_contents[$i][] = array('td' => '', |
|
208 | + $this->info_box_contents[$i][] = array('td' => '', |
|
209 | 209 | 'text' => dol_print_date($datem,'day')); |
210 | 210 | |
211 | - $this->info_box_contents[$i][] = array('td' => 'align="right" width="18"', |
|
211 | + $this->info_box_contents[$i][] = array('td' => 'align="right" width="18"', |
|
212 | 212 | 'text' => $contratlignestatic->LibStatut($objp->statut,3) |
213 | - ); |
|
214 | - |
|
215 | - $i++; |
|
216 | - } |
|
217 | - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoContractedProducts")); |
|
218 | - |
|
219 | - $db->free($result); |
|
220 | - } |
|
221 | - else |
|
222 | - { |
|
223 | - $this->info_box_contents[0][0] = array( 'td' => '', |
|
224 | - 'maxlength'=>500, |
|
225 | - 'text' => ($db->error().' sql='.$sql)); |
|
226 | - } |
|
227 | - } |
|
228 | - else { |
|
229 | - $this->info_box_contents[0][0] = array( |
|
230 | - 'td' => 'align="left" class="nohover opacitymedium"', |
|
213 | + ); |
|
214 | + |
|
215 | + $i++; |
|
216 | + } |
|
217 | + if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoContractedProducts")); |
|
218 | + |
|
219 | + $db->free($result); |
|
220 | + } |
|
221 | + else |
|
222 | + { |
|
223 | + $this->info_box_contents[0][0] = array( 'td' => '', |
|
224 | + 'maxlength'=>500, |
|
225 | + 'text' => ($db->error().' sql='.$sql)); |
|
226 | + } |
|
227 | + } |
|
228 | + else { |
|
229 | + $this->info_box_contents[0][0] = array( |
|
230 | + 'td' => 'align="left" class="nohover opacitymedium"', |
|
231 | 231 | 'text' => $langs->trans("ReadPermissionNotAllowed") |
232 | - ); |
|
233 | - } |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * Method to show box |
|
238 | - * |
|
239 | - * @param array $head Array with properties of box title |
|
240 | - * @param array $contents Array with properties of box lines |
|
241 | - * @param int $nooutput No print, only return string |
|
242 | - * @return string |
|
243 | - */ |
|
232 | + ); |
|
233 | + } |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * Method to show box |
|
238 | + * |
|
239 | + * @param array $head Array with properties of box title |
|
240 | + * @param array $contents Array with properties of box lines |
|
241 | + * @param int $nooutput No print, only return string |
|
242 | + * @return string |
|
243 | + */ |
|
244 | 244 | function showBox($head = null, $contents = null, $nooutput=0) |
245 | 245 | { |
246 | - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
247 | - } |
|
246 | + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
|
247 | + } |
|
248 | 248 | } |
249 | 249 |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class box_services_contracts extends ModeleBoxes |
34 | 34 | { |
35 | - var $boxcode="lastproductsincontract"; |
|
36 | - var $boximg="object_product"; |
|
37 | - var $boxlabel="BoxLastProductsInContract"; |
|
38 | - var $depends = array("service","contrat"); |
|
35 | + var $boxcode = "lastproductsincontract"; |
|
36 | + var $boximg = "object_product"; |
|
37 | + var $boxlabel = "BoxLastProductsInContract"; |
|
38 | + var $depends = array("service", "contrat"); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @var DoliDB Database handler. |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | * @param DoliDB $db Database handler |
55 | 55 | * @param string $param More parameters |
56 | 56 | */ |
57 | - function __construct($db,$param) |
|
57 | + function __construct($db, $param) |
|
58 | 58 | { |
59 | 59 | global $user; |
60 | 60 | |
61 | - $this->db=$db; |
|
61 | + $this->db = $db; |
|
62 | 62 | |
63 | - $this->hidden=! ($user->rights->service->lire && $user->rights->contrat->lire); |
|
63 | + $this->hidden = !($user->rights->service->lire && $user->rights->contrat->lire); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -69,66 +69,66 @@ discard block |
||
69 | 69 | * @param int $max Maximum number of records to load |
70 | 70 | * @return void |
71 | 71 | */ |
72 | - function loadBox($max=5) |
|
72 | + function loadBox($max = 5) |
|
73 | 73 | { |
74 | 74 | global $user, $langs, $db, $conf; |
75 | 75 | |
76 | - $this->max=$max; |
|
76 | + $this->max = $max; |
|
77 | 77 | |
78 | 78 | include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; |
79 | 79 | |
80 | 80 | $form = new Form($db); |
81 | 81 | |
82 | - $this->info_box_head = array('text' => $langs->trans("BoxLastProductsInContract",$max)); |
|
82 | + $this->info_box_head = array('text' => $langs->trans("BoxLastProductsInContract", $max)); |
|
83 | 83 | |
84 | 84 | if ($user->rights->service->lire && $user->rights->contrat->lire) |
85 | 85 | { |
86 | - $contractstatic=new Contrat($db); |
|
87 | - $contratlignestatic=new ContratLigne($db); |
|
86 | + $contractstatic = new Contrat($db); |
|
87 | + $contratlignestatic = new ContratLigne($db); |
|
88 | 88 | $thirdpartytmp = new Societe($db); |
89 | 89 | $productstatic = new Product($db); |
90 | 90 | |
91 | 91 | $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; |
92 | - $sql.= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; |
|
93 | - $sql.= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,"; |
|
94 | - $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity"; |
|
95 | - $sql.= " FROM (".MAIN_DB_PREFIX."societe as s"; |
|
96 | - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; |
|
97 | - $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; |
|
98 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; |
|
99 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
100 | - $sql.= ")"; |
|
101 | - $sql.= " WHERE c.entity = ".$conf->entity; |
|
102 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
103 | - $sql.= $db->order("c.tms","DESC"); |
|
104 | - $sql.= $db->plimit($max, 0); |
|
92 | + $sql .= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; |
|
93 | + $sql .= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,"; |
|
94 | + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity"; |
|
95 | + $sql .= " FROM (".MAIN_DB_PREFIX."societe as s"; |
|
96 | + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; |
|
97 | + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; |
|
98 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; |
|
99 | + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
100 | + $sql .= ")"; |
|
101 | + $sql .= " WHERE c.entity = ".$conf->entity; |
|
102 | + if ($user->societe_id) $sql .= " AND s.rowid = ".$user->societe_id; |
|
103 | + $sql .= $db->order("c.tms", "DESC"); |
|
104 | + $sql .= $db->plimit($max, 0); |
|
105 | 105 | |
106 | 106 | $result = $db->query($sql); |
107 | 107 | if ($result) |
108 | 108 | { |
109 | 109 | $num = $db->num_rows($result); |
110 | - $now=dol_now(); |
|
110 | + $now = dol_now(); |
|
111 | 111 | |
112 | 112 | $i = 0; |
113 | 113 | |
114 | 114 | while ($i < $num) |
115 | 115 | { |
116 | 116 | $objp = $db->fetch_object($result); |
117 | - $datem=$db->jdate($objp->datem); |
|
118 | - |
|
119 | - $contratlignestatic->id=$objp->cdid; |
|
120 | - $contratlignestatic->fk_contrat=$objp->rowid; |
|
121 | - $contratlignestatic->label=$objp->label; |
|
122 | - $contratlignestatic->description=$objp->description; |
|
123 | - $contratlignestatic->type=$objp->type; |
|
124 | - $contratlignestatic->product_id=$objp->product_id; |
|
125 | - $contratlignestatic->product_ref=$objp->product_ref; |
|
126 | - |
|
127 | - $contractstatic->statut=$objp->contract_status; |
|
128 | - $contractstatic->id=$objp->rowid; |
|
129 | - $contractstatic->ref=$objp->ref; |
|
130 | - $contractstatic->ref_customer=$objp->ref_customer; |
|
131 | - $contractstatic->ref_supplier=$objp->ref_supplier; |
|
117 | + $datem = $db->jdate($objp->datem); |
|
118 | + |
|
119 | + $contratlignestatic->id = $objp->cdid; |
|
120 | + $contratlignestatic->fk_contrat = $objp->rowid; |
|
121 | + $contratlignestatic->label = $objp->label; |
|
122 | + $contratlignestatic->description = $objp->description; |
|
123 | + $contratlignestatic->type = $objp->type; |
|
124 | + $contratlignestatic->product_id = $objp->product_id; |
|
125 | + $contratlignestatic->product_ref = $objp->product_ref; |
|
126 | + |
|
127 | + $contractstatic->statut = $objp->contract_status; |
|
128 | + $contractstatic->id = $objp->rowid; |
|
129 | + $contractstatic->ref = $objp->ref; |
|
130 | + $contractstatic->ref_customer = $objp->ref_customer; |
|
131 | + $contractstatic->ref_supplier = $objp->ref_supplier; |
|
132 | 132 | |
133 | 133 | $thirdpartytmp->name = $objp->name; |
134 | 134 | $thirdpartytmp->id = $objp->socid; |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; |
142 | 142 | |
143 | 143 | // Multilangs |
144 | - if (! empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) // if option multilang is on |
|
144 | + if (!empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) // if option multilang is on |
|
145 | 145 | { |
146 | 146 | $sqld = "SELECT label"; |
147 | - $sqld.= " FROM ".MAIN_DB_PREFIX."product_lang"; |
|
148 | - $sqld.= " WHERE fk_product=".$objp->product_id; |
|
149 | - $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; |
|
150 | - $sqld.= " LIMIT 1"; |
|
147 | + $sqld .= " FROM ".MAIN_DB_PREFIX."product_lang"; |
|
148 | + $sqld .= " WHERE fk_product=".$objp->product_id; |
|
149 | + $sqld .= " AND lang='".$langs->getDefaultLang()."'"; |
|
150 | + $sqld .= " LIMIT 1"; |
|
151 | 151 | |
152 | 152 | $resultd = $db->query($sqld); |
153 | 153 | if ($resultd) |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | // Label |
161 | 161 | if ($objp->product_id > 0) |
162 | 162 | { |
163 | - $productstatic->id=$objp->product_id; |
|
164 | - $productstatic->type=$objp->ptype; |
|
165 | - $productstatic->ref=$objp->product_ref; |
|
166 | - $productstatic->entity=$objp->pentity; |
|
167 | - $productstatic->label=$objp->plabel; |
|
168 | - $text = $productstatic->getNomUrl(1,'',20); |
|
163 | + $productstatic->id = $objp->product_id; |
|
164 | + $productstatic->type = $objp->ptype; |
|
165 | + $productstatic->ref = $objp->product_ref; |
|
166 | + $productstatic->entity = $objp->pentity; |
|
167 | + $productstatic->label = $objp->plabel; |
|
168 | + $text = $productstatic->getNomUrl(1, '', 20); |
|
169 | 169 | if ($objp->plabel) |
170 | 170 | { |
171 | 171 | $text .= ' - '; |
@@ -176,13 +176,13 @@ discard block |
||
176 | 176 | $description = $objp->description; |
177 | 177 | |
178 | 178 | // Add description in form |
179 | - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) |
|
179 | + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) |
|
180 | 180 | { |
181 | 181 | //$text .= (! empty($objp->description) && $objp->description!=$objp->plabel)?'<br>'.dol_htmlentitiesbr($objp->description):''; |
182 | - $description = ''; // Already added into main visible desc |
|
182 | + $description = ''; // Already added into main visible desc |
|
183 | 183 | } |
184 | 184 | |
185 | - $s = $form->textwithtooltip($text,$description,3,'','',$cursorline,0,(!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); |
|
185 | + $s = $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); |
|
186 | 186 | } |
187 | 187 | else |
188 | 188 | { |
@@ -206,21 +206,21 @@ discard block |
||
206 | 206 | ); |
207 | 207 | |
208 | 208 | $this->info_box_contents[$i][] = array('td' => '', |
209 | - 'text' => dol_print_date($datem,'day')); |
|
209 | + 'text' => dol_print_date($datem, 'day')); |
|
210 | 210 | |
211 | 211 | $this->info_box_contents[$i][] = array('td' => 'align="right" width="18"', |
212 | - 'text' => $contratlignestatic->LibStatut($objp->statut,3) |
|
212 | + 'text' => $contratlignestatic->LibStatut($objp->statut, 3) |
|
213 | 213 | ); |
214 | 214 | |
215 | 215 | $i++; |
216 | 216 | } |
217 | - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoContractedProducts")); |
|
217 | + if ($num == 0) $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text'=>$langs->trans("NoContractedProducts")); |
|
218 | 218 | |
219 | 219 | $db->free($result); |
220 | 220 | } |
221 | 221 | else |
222 | 222 | { |
223 | - $this->info_box_contents[0][0] = array( 'td' => '', |
|
223 | + $this->info_box_contents[0][0] = array('td' => '', |
|
224 | 224 | 'maxlength'=>500, |
225 | 225 | 'text' => ($db->error().' sql='.$sql)); |
226 | 226 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @param int $nooutput No print, only return string |
242 | 242 | * @return string |
243 | 243 | */ |
244 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
244 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
245 | 245 | { |
246 | 246 | return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
247 | 247 | } |
@@ -96,10 +96,14 @@ discard block |
||
96 | 96 | $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; |
97 | 97 | $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; |
98 | 98 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; |
99 | - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
99 | + if (!$user->rights->societe->client->voir && !$user->societe_id) { |
|
100 | + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
101 | + } |
|
100 | 102 | $sql.= ")"; |
101 | 103 | $sql.= " WHERE c.entity = ".$conf->entity; |
102 | - if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; |
|
104 | + if($user->societe_id) { |
|
105 | + $sql.= " AND s.rowid = ".$user->societe_id; |
|
106 | + } |
|
103 | 107 | $sql.= $db->order("c.tms","DESC"); |
104 | 108 | $sql.= $db->plimit($max, 0); |
105 | 109 | |
@@ -141,9 +145,11 @@ discard block |
||
141 | 145 | $thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur; |
142 | 146 | |
143 | 147 | // Multilangs |
144 | - if (! empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) // if option multilang is on |
|
148 | + if (! empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) { |
|
149 | + // if option multilang is on |
|
145 | 150 | { |
146 | 151 | $sqld = "SELECT label"; |
152 | + } |
|
147 | 153 | $sqld.= " FROM ".MAIN_DB_PREFIX."product_lang"; |
148 | 154 | $sqld.= " WHERE fk_product=".$objp->product_id; |
149 | 155 | $sqld.= " AND lang='". $langs->getDefaultLang() ."'"; |
@@ -153,7 +159,9 @@ discard block |
||
153 | 159 | if ($resultd) |
154 | 160 | { |
155 | 161 | $objtp = $db->fetch_object($resultd); |
156 | - if ($objtp->label != '') $contratlignestatic->label = $objtp->label; |
|
162 | + if ($objtp->label != '') { |
|
163 | + $contratlignestatic->label = $objtp->label; |
|
164 | + } |
|
157 | 165 | } |
158 | 166 | } |
159 | 167 | |
@@ -183,8 +191,7 @@ discard block |
||
183 | 191 | } |
184 | 192 | |
185 | 193 | $s = $form->textwithtooltip($text,$description,3,'','',$cursorline,0,(!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); |
186 | - } |
|
187 | - else |
|
194 | + } else |
|
188 | 195 | { |
189 | 196 | $s = img_object($langs->trans("ShowProductOrService"), ($objp->product_type ? 'service' : 'product')).' '.dol_htmlentitiesbr($objp->description); |
190 | 197 | } |
@@ -214,18 +221,18 @@ discard block |
||
214 | 221 | |
215 | 222 | $i++; |
216 | 223 | } |
217 | - if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoContractedProducts")); |
|
224 | + if ($num==0) { |
|
225 | + $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoContractedProducts")); |
|
226 | + } |
|
218 | 227 | |
219 | 228 | $db->free($result); |
220 | - } |
|
221 | - else |
|
229 | + } else |
|
222 | 230 | { |
223 | 231 | $this->info_box_contents[0][0] = array( 'td' => '', |
224 | 232 | 'maxlength'=>500, |
225 | 233 | 'text' => ($db->error().' sql='.$sql)); |
226 | 234 | } |
227 | - } |
|
228 | - else { |
|
235 | + } else { |
|
229 | 236 | $this->info_box_contents[0][0] = array( |
230 | 237 | 'td' => 'align="left" class="nohover opacitymedium"', |
231 | 238 | 'text' => $langs->trans("ReadPermissionNotAllowed") |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \ingroup ticket |
23 | 23 | * \brief This box shows latest created tickets |
24 | 24 | */ |
25 | -require_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; |
|
25 | +require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Class to manage the box |
@@ -82,17 +82,17 @@ discard block |
||
82 | 82 | $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; |
83 | 83 | $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; |
84 | 84 | $sql .= ", s.nom as company_name"; |
85 | - $sql .= " FROM " . MAIN_DB_PREFIX . "ticket as t"; |
|
86 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_type as type ON type.code=t.type_code"; |
|
87 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_category as category ON category.code=t.category_code"; |
|
88 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_severity as severity ON severity.code=t.severity_code"; |
|
89 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid=t.fk_soc"; |
|
85 | + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; |
|
86 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; |
|
87 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; |
|
88 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; |
|
89 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; |
|
90 | 90 | |
91 | - $sql .= " WHERE t.entity = " . $conf->entity; |
|
91 | + $sql .= " WHERE t.entity = ".$conf->entity; |
|
92 | 92 | // $sql.= " AND e.rowid = er.fk_event"; |
93 | 93 | //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
94 | 94 | if ($user->societe_id) { |
95 | - $sql .= " AND t.fk_soc= " . $user->societe_id; |
|
95 | + $sql .= " AND t.fk_soc= ".$user->societe_id; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | //$sql.= " AND t.fk_statut > 9"; |
@@ -122,21 +122,21 @@ discard block |
||
122 | 122 | $this->info_box_contents[$i][0] = array( |
123 | 123 | 'td' => 'align="left" width="16"', |
124 | 124 | 'logo' => $this->boximg, |
125 | - 'url' => dol_buildpath("/ticket/card.php?track_id=" . $objp->track_id, 1)); |
|
125 | + 'url' => dol_buildpath("/ticket/card.php?track_id=".$objp->track_id, 1)); |
|
126 | 126 | $r++; |
127 | 127 | |
128 | 128 | // Id |
129 | 129 | $this->info_box_contents[$i][$r] = array( |
130 | 130 | 'td' => 'align="left"', |
131 | 131 | 'text' => $objp->ref, |
132 | - 'url' => dol_buildpath("/ticket/card.php?track_id=" . $objp->track_id, 1)); |
|
132 | + 'url' => dol_buildpath("/ticket/card.php?track_id=".$objp->track_id, 1)); |
|
133 | 133 | $r++; |
134 | 134 | |
135 | 135 | // Subject |
136 | 136 | $this->info_box_contents[$i][$r] = array( |
137 | 137 | 'td' => 'align="left"', |
138 | 138 | 'text' => $objp->subject, // Some event have no ref |
139 | - 'url' => dol_buildpath("/ticket/card.php?track_id=" . $objp->track_id, 1)); |
|
139 | + 'url' => dol_buildpath("/ticket/card.php?track_id=".$objp->track_id, 1)); |
|
140 | 140 | $r++; |
141 | 141 | |
142 | 142 | // Customer |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | 'td' => 'align="left"', |
145 | 145 | 'logo' => ($objp->fk_soc > 0 ? 'company' : ''), |
146 | 146 | 'text' => ($objp->company_name ? $objp->company_name : $objp->origin_email), |
147 | - 'url' => ($objp->fk_soc > 0 ? DOL_URL_ROOT . "/comm/card.php?socid=" . $objp->fk_soc : ''), |
|
147 | + 'url' => ($objp->fk_soc > 0 ? DOL_URL_ROOT . "/comm/card.php?socid=".$objp->fk_soc : ''), |
|
148 | 148 | ); |
149 | 149 | $r++; |
150 | 150 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param int $nooutput No print, only return string |
188 | 188 | * @return string |
189 | 189 | */ |
190 | - function showBox($head = null, $contents = null, $nooutput=0) |
|
190 | + function showBox($head = null, $contents = null, $nooutput = 0) |
|
191 | 191 | { |
192 | 192 | parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); |
193 | 193 | } |