dolibarr  13.0.2
photos_resize.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2010-2015 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2009 Meos
4  * Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
30 
31 // Load translation files required by the page
32 $langs->loadLangs(array("products", "other"));
33 
34 $id = GETPOST('id', 'int');
35 $action = GETPOST('action', 'aZ09');
36 $modulepart = GETPOST('modulepart', 'alpha') ?GETPOST('modulepart', 'alpha') : 'produit|service';
37 $original_file = GETPOST("file");
38 $backtourl = GETPOST('backtourl');
39 $cancel = GETPOST('cancel', 'alpha');
40 
41 $file = GETPOST('file', 'alpha');
42 $num = GETPOST('num', 'alpha'); // Used for document on bank statement
43 $website = GETPOST('website', 'alpha');
44 
45 
46 // Security check
47 if (empty($modulepart)) accessforbidden('Bad value for modulepart');
48 $accessallowed = 0;
49 if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service')
50 {
51  $result = restrictedArea($user, 'produit|service', $id, 'product&product');
52  if ($modulepart == 'produit|service' && (!$user->rights->produit->lire && !$user->rights->service->lire)) accessforbidden();
53  $accessallowed = 1;
54 } elseif ($modulepart == 'project')
55 {
56  $result = restrictedArea($user, 'projet', $id);
57  if (!$user->rights->projet->lire) accessforbidden();
58  $accessallowed = 1;
59 } elseif ($modulepart == 'bom')
60 {
61  $result = restrictedArea($user, $modulepart, $id, 'bom_bom');
62  if (!$user->rights->bom->read) accessforbidden();
63  $accessallowed = 1;
64 } elseif ($modulepart == 'member')
65 {
66  $result = restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid');
67  if (!$user->rights->adherent->lire) accessforbidden();
68  $accessallowed = 1;
69 } elseif ($modulepart == 'user')
70 {
71  $result = restrictedArea($user, $modulepart, $id, $modulepart);
72  if (!$user->rights->user->user->lire) accessforbidden();
73  $accessallowed = 1;
74 } elseif ($modulepart == 'tax')
75 {
76  $result = restrictedArea($user, $modulepart, $id, 'chargesociales', 'charges');
77  if (!$user->rights->tax->charges->lire) accessforbidden();
78  $accessallowed = 1;
79 } elseif ($modulepart == 'bank')
80 {
81  $result = restrictedArea($user, 'banque', $id, 'bank_account');
82  if (!$user->rights->banque->lire) accessforbidden();
83  $accessallowed = 1;
84 } elseif ($modulepart == 'medias')
85 {
86  $permtoadd = ($user->rights->mailing->creer || $user->rights->website->write);
87  if (!$permtoadd) accessforbidden();
88  $accessallowed = 1;
89 } elseif ($modulepart == 'facture_fourn' || $modulepart == 'facture_fournisseur')
90 {
91  $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
92  if (!$user->rights->fournisseur->facture->lire) accessforbidden();
93  $accessallowed = 1;
94 } else // ticket, holiday, expensereport, societe...
95 {
96  $result = restrictedArea($user, $modulepart, $id, $modulepart);
97  if (empty($user->rights->$modulepart->read) && empty($user->rights->$modulepart->lire)) accessforbidden();
98  $accessallowed = 1;
99 }
100 
101 // Security:
102 // Limit access if permissions are wrong
103 if (!$accessallowed)
104 {
105  accessforbidden();
106 }
107 
108 // Define dir according to modulepart
109 if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'service' || $modulepart == 'produit|service')
110 {
111  require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
112  $object = new Product($db);
113  if ($id > 0)
114  {
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];
120  }
121 } elseif ($modulepart == 'project')
122 {
123  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
124  $object = new Project($db);
125  if ($id > 0)
126  {
127  $result = $object->fetch($id);
128  if ($result <= 0) dol_print_error($db, 'Failed to load object');
129  $dir = $conf->project->multidir_output[$object->entity]; // By default
130  }
131 } elseif ($modulepart == 'propal')
132 {
133  require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
134  $object = new Propal($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->propal->multidir_output[$object->entity]; // By default
140  }
141 } elseif ($modulepart == 'holiday')
142 {
143  require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
144  $object = new Holiday($db);
145  if ($id > 0)
146  {
147  $result = $object->fetch($id);
148  if ($result <= 0) dol_print_error($db, 'Failed to load object');
149  $dir = $conf->$modulepart->dir_output; // By default
150  }
151 } elseif ($modulepart == 'member')
152 {
153  require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
154  $object = new Adherent($db);
155  if ($id > 0)
156  {
157  $result = $object->fetch($id);
158  if ($result <= 0) dol_print_error($db, 'Failed to load object');
159  $dir = $conf->adherent->dir_output; // By default
160  }
161 } elseif ($modulepart == 'societe')
162 {
163  require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
164  $object = new Societe($db);
165  if ($id > 0)
166  {
167  $result = $object->fetch($id);
168  if ($result <= 0) dol_print_error($db, 'Failed to load object');
169  $dir = $conf->$modulepart->dir_output;
170  }
171 } elseif ($modulepart == 'user')
172 {
173  require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
174  $object = new User($db);
175  if ($id > 0)
176  {
177  $result = $object->fetch($id);
178  if ($result <= 0) dol_print_error($db, 'Failed to load object');
179  $dir = $conf->$modulepart->dir_output; // By default
180  }
181 } elseif ($modulepart == 'expensereport')
182 {
183  require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
184  $object = new ExpenseReport($db);
185  if ($id > 0)
186  {
187  $result = $object->fetch($id);
188  if ($result <= 0) dol_print_error($db, 'Failed to load object');
189  $dir = $conf->expensereport->dir_output; // By default
190  }
191 } elseif ($modulepart == 'tax')
192 {
193  require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
194  $object = new ChargeSociales($db);
195  if ($id > 0)
196  {
197  $result = $object->fetch($id);
198  if ($result <= 0) dol_print_error($db, 'Failed to load object');
199  $dir = $conf->$modulepart->dir_output; // By default
200  }
201 } elseif ($modulepart == 'ticket')
202 {
203  require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
204  $object = new Ticket($db);
205  if ($id > 0)
206  {
207  $result = $object->fetch($id);
208  if ($result <= 0) dol_print_error($db, 'Failed to load object');
209  $dir = $conf->$modulepart->dir_output; // By default
210  }
211 } elseif ($modulepart == 'bom')
212 {
213  require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
214  $object = new BOM($db);
215  if ($id > 0)
216  {
217  $result = $object->fetch($id);
218  if ($result <= 0) dol_print_error($db, 'Failed to load object');
219  $dir = $conf->$modulepart->dir_output; // By default
220  }
221 } elseif ($modulepart == 'mrp') {
222  require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php';
223  $object = new MO($db);
224  if ($id > 0)
225  {
226  $result = $object->fetch($id);
227  if ($result <= 0) dol_print_error($db, 'Failed to load object');
228  $dir = $conf->$modulepart->dir_output; // By default
229  }
230 } elseif ($modulepart == 'bank') {
231  require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
232  $object = new Account($db);
233  if ($id > 0)
234  {
235  $result = $object->fetch($id);
236  if ($result <= 0) dol_print_error($db, 'Failed to load object');
237  $dir = $conf->bank->dir_output; // By default
238  }
239 } elseif ($modulepart == 'facture') {
240  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
241  $object = new Facture($db);
242  if ($id > 0)
243  {
244  $result = $object->fetch($id);
245  if ($result <= 0) dol_print_error($db, 'Failed to load object');
246  $dir = $conf->$modulepart->dir_output; // By default
247  }
248 } elseif ($modulepart == 'facture_fourn' || $modulepart == 'facture_fournisseur') {
249  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
250  $object = new FactureFournisseur($db);
251  if ($id > 0)
252  {
253  $result = $object->fetch($id);
254  if ($result <= 0) dol_print_error($db, 'Failed to load object');
255  $dir = $conf->fournisseur->dir_output.'/facture'; // By default
256  }
257 } elseif ($modulepart == 'medias') {
258  $dir = $dolibarr_main_data_root.'/'.$modulepart;
259 } else {
260  print 'Bug: Action crop for modulepart = '.$modulepart.' is not supported yet by photos_resize.php.';
261 }
262 
263 if (empty($backtourl))
264 {
265  $regs = array();
266 
267  if (in_array($modulepart, array('product', 'produit', 'service', 'produit|service'))) $backtourl = DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($file);
268  elseif (in_array($modulepart, array('expensereport'))) $backtourl = DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($file);
269  elseif (in_array($modulepart, array('holiday'))) $backtourl = DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($file);
270  elseif (in_array($modulepart, array('member'))) $backtourl = DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($file);
271  elseif (in_array($modulepart, array('project'))) $backtourl = DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($file);
272  elseif (in_array($modulepart, array('propal'))) $backtourl = DOL_URL_ROOT."/comm/propal/document.php?id=".$id.'&file='.urldecode($file);
273  elseif (in_array($modulepart, array('societe'))) $backtourl = DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($file);
274  elseif (in_array($modulepart, array('tax'))) $backtourl = DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($file);
275  elseif (in_array($modulepart, array('ticket'))) $backtourl = DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($file);
276  elseif (in_array($modulepart, array('user'))) $backtourl = DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($file);
277  elseif (in_array($modulepart, array('facture'))) $backtourl = DOL_URL_ROOT."/compta/facture/document.php?id=".$id.'&file='.urldecode($file);
278  elseif (in_array($modulepart, array('facture_fourn', 'facture_fournisseur'))) $backtourl = DOL_URL_ROOT."/fourn/facture/document.php?id=".$id.'&file='.urldecode($file);
279  elseif (in_array($modulepart, array('bank')) && preg_match('/\/statement\/([^\/]+)\//', $file, $regs)) {
280  $num = $regs[1];
281  $backtourl = DOL_URL_ROOT."/compta/bank/account_statement_document.php?id=".$id.'&num='.urlencode($num).'&file='.urldecode($file);
282  } elseif (in_array($modulepart, array('bank'))) $backtourl = DOL_URL_ROOT."/compta/bank/document.php?id=".$id.'&file='.urldecode($file);
283  elseif (in_array($modulepart, array('mrp'))) $backtourl = DOL_URL_ROOT."/mrp/mo_document.php?id=".$id.'&file='.urldecode($file);
284  elseif (in_array($modulepart, array('medias'))) {
285  $section_dir = dirname($file);
286  if (!preg_match('/\/$/', $section_dir)) $section_dir .= '/';
287  $backtourl = DOL_URL_ROOT."/website/index.php?action=file_manager&website=".$website.'&section_dir='.urlencode($section_dir);
288  }
289  // Generic case that should work for everybody else
290  else $backtourl = DOL_URL_ROOT."/".$modulepart."/".$modulepart."_document.php?id=".$id.'&file='.urldecode($file);
291 }
292 
293 
294 /*
295  * Actions
296  */
297 
298 if ($cancel) {
299  if ($backtourl) {
300  header("Location: ".$backtourl);
301  exit;
302  } else {
303  dol_print_error('', 'Cancel on photo_resize with a not supported value of modulepart='.$modulepart);
304  exit;
305  }
306 }
307 
308 if ($action == 'confirm_resize' && GETPOSTISSET("file") && GETPOSTISSET("sizex") && GETPOSTISSET("sizey"))
309 {
310  if (empty($dir)) {
311  print 'Bug: Value for $dir could not be defined.';
312  }
313 
314  $fullpath = $dir."/".$original_file;
315 
316  $result = dol_imageResizeOrCrop($fullpath, 0, GETPOST('sizex', 'int'), GETPOST('sizey', 'int'));
317 
318  if ($result == $fullpath)
319  {
320  // If image is related to a given object, we create also thumbs.
321  if (is_object($object)) {
322  $object->addThumbs($fullpath);
323  }
324 
325  // Update/create database for file $fullpath
326  $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $fullpath);
327  $rel_filename = preg_replace('/^[\\/]/', '', $rel_filename);
328 
329  include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
330  $ecmfile = new EcmFiles($db);
331  $result = $ecmfile->fetch(0, '', $rel_filename);
332  if ($result > 0) // If found
333  {
334  $filename = basename($rel_filename);
335  $rel_dir = dirname($rel_filename);
336  $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
337  $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
338 
339  $ecmfile->label = md5_file(dol_osencode($fullpath));
340  $result = $ecmfile->update($user);
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  } else {
368  dol_print_error('', 'confirm_resize on photo_resize without backtourl defined for modulepart='.$modulepart);
369  exit;
370  }
371  } else {
372  setEventMessages($result, null, 'errors');
373  $_GET['file'] = $_POST["file"];
374  $action = '';
375  }
376 }
377 
378 // Crop d'une image
379 if ($action == 'confirm_crop')
380 {
381  if (empty($dir)) {
382  print 'Bug: Value for $dir could not be defined.';
383  }
384 
385  $fullpath = $dir."/".$original_file;
386 
387  //var_dump($fullpath.' '.$_POST['w'].'x'.$_POST['h'].'-'.$_POST['x'].'x'.$_POST['y']);exit;
388  $result = dol_imageResizeOrCrop($fullpath, 1, GETPOST('w', 'int'), GETPOST('h', 'int'), GETPOST('x', 'int'), GETPOST('y', 'int'));
389 
390  if ($result == $fullpath)
391  {
392  if (is_object($object)) {
393  $object->addThumbs($fullpath);
394  }
395 
396  // Update/create database for file $fullpath
397  $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $fullpath);
398  $rel_filename = preg_replace('/^[\\/]/', '', $rel_filename);
399 
400  include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
401  $ecmfile = new EcmFiles($db);
402  $result = $ecmfile->fetch(0, '', $rel_filename);
403  if ($result > 0) // If found
404  {
405  $filename = basename($rel_filename);
406  $rel_dir = dirname($rel_filename);
407  $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
408  $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
409 
410  $ecmfile->label = md5_file(dol_osencode($fullpath));
411  $result = $ecmfile->update($user);
412  } elseif ($result == 0) // If not found
413  {
414  $filename = basename($rel_filename);
415  $rel_dir = dirname($rel_filename);
416  $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
417  $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
418 
419  $ecmfile->filepath = $rel_dir;
420  $ecmfile->filename = $filename;
421  $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file
422  $ecmfile->fullpath_orig = $fullpath;
423  $ecmfile->gen_or_uploaded = 'unknown';
424  $ecmfile->description = ''; // indexed content
425  $ecmfile->keyword = ''; // keyword content
426  $result = $ecmfile->create($user);
427  if ($result < 0)
428  {
429  setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
430  }
431  $result = $ecmfile->create($user);
432  }
433 
434  if ($backtourl) {
435  header("Location: ".$backtourl);
436  exit;
437  } else {
438  dol_print_error('', 'confirm_crop on photo_resize without backtourl defined for modulepart='.$modulepart);
439  exit;
440  }
441  } else {
442  setEventMessages($result, null, 'errors');
443  $_GET['file'] = $_POST["file"];
444  $action = '';
445  }
446 }
447 
448 
449 /*
450  * View
451  */
452 
453 $title= $langs->trans("ImageEditor");
454 
455 llxHeader($head, $title, '', '', 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'));
456 
457 
458 print load_fiche_titre($title);
459 
460 $infoarray = dol_getImageSize($dir."/".GETPOST("file", 'alpha'));
461 $height = $infoarray['height'];
462 $width = $infoarray['width'];
463 print $langs->trans("CurrentInformationOnImage").': ';
464 print $langs->trans("Width").': <strong>'.$width.'</strong> x '.$langs->trans("Height").': <strong>'.$height.'</strong><br>';
465 
466 print '<br>'."\n";
467 
468 
469 /*
470  * Resize image
471  */
472 
473 print '<!-- Form to resize -->'."\n";
474 print '<form name="redim_file" action="'.$_SERVER["PHP_SELF"].'?id='.$id.($num ? '&num='.$num : '').'" method="POST">';
475 print '<input type="hidden" name="token" value="'.newToken().'">';
476 
477 print '<fieldset id="redim_file">';
478 print '<legend>'.$langs->trans("Resize").'</legend>';
479 print $langs->trans("ResizeDesc").'<br>';
480 print $langs->trans("NewLength").': <input name="sizex" type="number" class="flat maxwidth50"> px &nbsp; '.$langs->trans("or").' &nbsp; ';
481 print $langs->trans("NewHeight").': <input name="sizey" type="number" class="flat maxwidth50"> px &nbsp; <br>';
482 
483 print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'" />';
484 print '<input type="hidden" name="action" value="confirm_resize" />';
485 print '<input type="hidden" name="product" value="'.$id.'" />';
486 print '<input type="hidden" name="modulepart" value="'.dol_escape_htmltag($modulepart).'" />';
487 print '<input type="hidden" name="id" value="'.$id.'" />';
488 print '<br>';
489 print '<input class="button" id="submitresize" name="sendit" value="'.dol_escape_htmltag($langs->trans("Resize")).'" type="submit" />';
490 print '&nbsp;';
491 print '<input type="submit" id="cancelresize" name="cancel" class="button button-cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" />';
492 print '</fieldset>'."\n";
493 print '</form>';
494 print '<br>'."\n";
495 
496 
497 /*
498  * Crop image
499  */
500 
501 print '<br>'."\n";
502 
503 if (!empty($conf->use_javascript_ajax))
504 {
505  $infoarray = dol_getImageSize($dir."/".GETPOST("file"));
506  $height = $infoarray['height'];
507  $width = $infoarray['width'];
508  $widthforcrop = $width; $refsizeforcrop = 'orig'; $ratioforcrop = 1;
509  // If image is too large, we use another scale.
510  if (!empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth'] / 2)))
511  {
512  $ratioforcrop = 2;
513  $widthforcrop = round($_SESSION['dol_screenwidth'] / $ratioforcrop);
514  $refsizeforcrop = 'screenwidth';
515  }
516 
517  print '<!-- Form to crop -->'."\n";
518  print '<fieldset id="redim_file">';
519  print '<legend>'.$langs->trans("Recenter").'</legend>';
520  print $langs->trans("DefineNewAreaToPick").'...<br>';
521  print '<br><div class="center">';
522  print '<div style="border: 1px solid #888888; width: '.$widthforcrop.'px;">';
523  print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($original_file).'" alt="" id="cropbox" width="'.$widthforcrop.'px"/>';
524  print '</div>';
525  print '</div><br>';
526 
527  print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.($num ? '&num='.$num : '').'" method="POST">';
528  print '<input type="hidden" name="token" value="'.newToken().'">';
529  print '
530  <div class="jc_coords">
531  '.$langs->trans("NewSizeAfterCropping").':
532  <label>X1 <input type="number" class="flat maxwidth50" id="x" name="x" /></label>
533  <label>Y1 <input type="number" class="flat maxwidth50" id="y" name="y" /></label>
534  <label>X2 <input type="number" class="flat maxwidth50" id="x2" name="x2" /></label>
535  <label>Y2 <input type="number" class="flat maxwidth50" id="y2" name="y2" /></label>
536  <label>W <input type="number" class="flat maxwidth50" id="w" name="w" /></label>
537  <label>H <input type="number" class="flat maxwidth50" id="h" name="h" /></label>
538  </div>
539 
540  <input type="hidden" id="file" name="file" value="'.dol_escape_htmltag($original_file).'" />
541  <input type="hidden" id="action" name="action" value="confirm_crop" />
542  <input type="hidden" id="product" name="product" value="'.dol_escape_htmltag($id).'" />
543  <input type="hidden" id="refsizeforcrop" name="refsizeforcrop" value="'.$refsizeforcrop.'" />
544  <input type="hidden" id="ratioforcrop" name="ratioforcrop" value="'.$ratioforcrop.'" /><!-- field used by core/lib/lib_photoresize.js -->
545  <input type="hidden" name="modulepart" value="'.dol_escape_htmltag($modulepart).'" />
546  <input type="hidden" name="id" value="'.dol_escape_htmltag($id).'" />
547  <br>
548  <input type="submit" id="submitcrop" name="submitcrop" class="button" value="'.dol_escape_htmltag($langs->trans("Recenter")).'" />
549  &nbsp;
550  <input type="submit" id="cancelcrop" name="cancel" class="button button-cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" />
551  </form>'."\n";
552  print '</fieldset>'."\n";
553  print '<br>';
554 }
555 
556 /* Check that mandatory fields are filled */
557 print '<script type="text/javascript" language="javascript">
558 jQuery(document).ready(function() {
559  $("#submitcrop").click(function(e) {
560  console.log("We click on submitcrop");
561  var idClicked = e.target.id;
562  if (parseInt(jQuery(\'#w\').val())) return true;
563  alert(\''.dol_escape_js($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Dimension"))).'\');
564  return false;
565  });
566 });
567 </script>';
568 
569 llxFooter();
570 $db->close();
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class of the module paid holiday.
dol_getImageSize($file, $url=false)
Return size of image file on disk (Supported extensions are gif, jpg, png and bmp) ...
Definition: images.lib.php:86
Class for BOM.
Definition: bom.class.php:32
Class to manage products or services.
Class to manage Dolibarr users.
Definition: user.class.php:44
const TYPE_SERVICE
Service.
Class to manage suppliers invoices.
const TYPE_PRODUCT
Regular product.
Class to manage ticket.
Class to manage bank accounts.
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage projects.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
$conf db user
Definition: repair.php:109
Class to manage members of a foundation.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage Trips and Expenses.
print
Draft customers invoices.
Definition: index.php:89
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Class to manage invoices.
Classe permettant la gestion des paiements des charges La tva collectee n&#39;est calculee que sur les fa...
Class to manage ECM files.
dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $src_y=0)
Resize or crop an image file (Supported extensions are gif, jpg, png and bmp)
Definition: images.lib.php:120
Class to manage proposals.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...