From 9f1786ca6e7935bb5390cbd094537ae32271e78f Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Thu, 10 Mar 2005 16:40:54 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20m=E9thode=20pour=20la=20gestion=20des?= =?UTF-8?q?=20photos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/product.class.php | 60 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) 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 '
'; + } + } + + } }