diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 9d1461d4416..06ac538cccd 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -860,16 +860,74 @@ class Product * * */ - function add_photo($sdir) + function add_photo($sdir, $files) { + $dir = $sdir .'/'. get_exdir($this->id) . $this->id ."/"; + $dir .= "photos/"; + if (! file_exists($dir)) { dolibarr_syslog("Product Create $dir"); create_exdir($dir); } + if ( file_exists($dir)) + { + if (doliMoveFileUpload($files['tmp_name'], $dir . $files['name'])) + { + + } + } + } + /** + * + * + */ + function show_photo($sdir) + { + $photo = ''; + $pdir = get_exdir($this->id) . $this->id ."/photos/"; + $dir = $sdir . '/'. $pdir; + + $handle=opendir($dir); + + while (($file = readdir($handle))!==false) + { + if (is_file($dir.$file)) + { + $photo = $file; + } + } + + if (strlen($photo)) + { + print ''; + } + } + /** + * Je sais c'est sale mais le besoin est urgent ;-) + * + */ + function show_photos($sdir) + { + $photo = ''; + $pdir = get_exdir($this->id) . $this->id ."/photos/"; + $dir = $sdir . '/'. $pdir; + + $handle=opendir($dir); + + while (($file = readdir($handle))!==false) + { + if (is_file($dir.$file)) + { + $photo = $file; + print '
'; + } + } + + } }