Exemple #1
0
 public function uploadFirmDetails($form, $request, $baseurl)
 {
     try {
         $postData = $request->getPost();
         $restaurantModel = new Restaurant_Model_Restaurant();
         $restaurantModel->setOptions($postData);
         $restaurantMapper = new Restaurant_Model_RestaurantMapper();
         $locationMapper = new Application_Model_LocationboundariesMapper();
         $location_name = $locationMapper->getLocationName($restaurantModel->getReslocation_id());
         $resid = $restaurantMapper->saveRestaurantData($restaurantModel, $location_name);
         if (is_numeric($resid)) {
             $image_path = null;
             $logopath = null;
             $uploadpath = $_SERVER['DOCUMENT_ROOT'] . $baseurl . "/uploads/Restaurant_images/{$resid}/";
             if (!file_exists($uploadpath)) {
                 $dir = mkdir($uploadpath, 0777, true);
             }
             $uploadpath .= "resimages/";
             if (!file_exists($uploadpath)) {
                 $dir = mkdir($uploadpath, 0777, true);
             }
             $imageName = null;
             $imagepath = array();
             $imageAdapter = $form->res_image_button->getTransferAdapter();
             if (file_exists($uploadpath)) {
                 if ($imageAdapter && $resid) {
                     $i = -1;
                     foreach ($imageAdapter->getFileInfo() as $info) {
                         if ($i != -1) {
                             if ($info['name'] != null) {
                                 $namearr = explode(".", $info['name']);
                                 $ext = $namearr[sizeof($namearr) - 1];
                                 $fileName = 'image' . $i . '.' . $ext;
                                 foreach ($info as $filenames) {
                                     $imageAdapter->setFilters(array(new Zend_Filter_File_Rename(array('target' => $uploadpath . $fileName, $filenames, 'overwrite' => true))));
                                 }
                                 if ($imageAdapter->receive($info['name'])) {
                                     $image_path = $uploadpath . $fileName;
                                     $imagepath[] = $image_path;
                                 }
                                 $i++;
                             } else {
                                 $i++;
                                 $imagepath[] = "";
                             }
                         } else {
                             $i++;
                         }
                     }
                 }
             }
         }
         return $resid;
     } catch (Exception $ex) {
         Rdine_Logger_FileLogger::info($ex->getMessage());
         throw new Exception($ex->getMessage());
     }
 }
 public function getRestaurant($rid)
 {
     try {
         $db = $this->getDbTable();
         $data = array();
         $select = $db->select()->from(array('rd' => 'rd.restaurant_details'))->join(array('citybd' => 'rd.city_bd'), 'rd.rescity_id = citybd.id', array('rescity_name' => 'citybd.description'))->join(array('locationbd' => 'rd.location_boundaries'), 'rd.reslocation_id = locationbd.id', array('reslocation_name' => 'locationbd.description'))->joinLeft(array('rbd' => 'rd.restaurant_type_bd'), 'rbd.id= rd.restype_id', array('restypedescription' => 'rbd.description'))->setIntegrityCheck(false)->ORwhere("resid =?", $rid);
         $stmt = $select->query();
         $results = $stmt->fetchAll();
         foreach ($results as $value) {
             $obj = new Restaurant_Model_Restaurant();
             $data[] = $obj->setOptions($value);
         }
         return $data;
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }