public function ajaxuploadtopbannerAction() { //print_r($_FILES);exit; $name = $_FILES['Filedata']['name'] = '1' . '_' . time() . str_ireplace(array(' ', '_', '-', ','), '', strtolower($_FILES['Filedata']['name'])); $_FILES['Filedata']['type'] = 'image'; $fileHandler = new FM_Components_Util_UploadHandler($_FILES['Filedata']); $mediaFolder = $_POST['type'] == 'icon' ? 'icons' : 'logos'; $folder = $fileHandler->setFolder($mediaFolder); if ($fileHandler->move()) { list($width, $height, $type, $attr) = getimagesize($_SERVER['DOCUMENT_ROOT'] . $folder . '/' . $name); //if($width > $_POST['width'] || $height > $_POST['height']) { // print '0'; // exit; //} $insertData['fileName'] = $name; $insertData['width'] = $width; $insertData['height'] = $height; $insertData['type'] = 'LG'; $insertData['active'] = '1'; //$insertData['orgId'] = $id; $returns = array('src' => $folder . '/' . $name, 'height' => $height, 'width' => $width); print Zend_Json::encode($returns); if ($_POST['type'] == 'left') { $banner = new FM_Components_Util_Logo(array('orgId' => $_POST['orgId'])); if (trim($banner->getId()) != '') { FM_Components_Util_Logo::updateBanner(array('orgId' => $_POST['orgId']), $insertData); } else { $insertData['orgId'] = $_POST['orgId']; FM_Components_Util_Logo::insert($insertData); } } if ($_POST['type'] == 'right') { $banner = new FM_Components_Util_MiniwebBanner(array('orgId' => $_POST['orgId'])); if (trim($banner->getId()) != '') { FM_Components_Util_MiniwebBanner::updateBanner(array('orgId' => $_POST['orgId']), $insertData); } else { $insertData['orgId'] = $_POST['orgId']; FM_Components_Util_MiniwebBanner::insert($insertData); } } if ($_POST['type'] == 'icon') { $icon = new FM_Components_Util_Icon(array('orgId' => $_POST['orgId'])); //print_r($icon); if (trim($icon->getId()) != '') { FM_Components_Util_Icon::updateIcon(array('orgId' => $_POST['orgId']), $insertData); } else { $insertData['orgId'] = $_POST['orgId']; FM_Components_Util_Icon::insert($insertData); } } //($_POST['type'] == 'left') ? FM_Components_Util_Logo::insert(array($insertData)) : FM_Components_Util_MiniwebBanner::insert(array($insertData)); exit; } }
public function addbusinessAction() { $this->view->org = 'b2b'; $this->view->search = new FM_Forms_Register_Search(); $this->view->catJumper = new FM_Forms_Register_CatJumper(); $this->subcat = 'business'; $this->view->tiny = true; if ($_GET['delete']) { FM_Components_Business::delete(array('id' => $_GET['delete'])); $this->_redirect('/root/addbusiness'); } else { $this->view->sidenav = $this->view->partial('root/parts/sidenavs/organizations.phtml', array('org' => 'b2b')); $pc = new FM_Models_FM_SearchPrimaryCategories(); $this->view->catSelect = $category = new Zend_Form_Element_Multiselect(array('label' => 'category :', 'name' => 'category', 'required' => 1)); foreach ($pc->getPrimaryCategories() as $index => $values) { $category->addMultiOption($values['id'], $values['name']); } if ($_POST['search']) { $businesses = FM_Components_Organization::getOrgsLike($_POST['search'], 2); } elseif ($this->_getParam('category') > 0 && $this->_getParam('category') != '117') { $catname = FM_Components_Util_Category::getCategoryName($this->_getParam('category'), false); $businesses = FM_Components_Business::getByCategoryForRoot($this->_getParam('category')); } elseif ($this->_getParam('category') == '117') { $businesses = FM_Components_Business::getActiveForRoot(); $catname = 'all'; } else { $businesses = array(); } $this->view->clients = $this->view->partial('root/business/clientindex.phtml', array('clients' => $businesses, 'catname' => $catname)); $this->view->form = $businessForm = new FM_Forms_Register_Business(array(), FM_Components_Member::getAll()); //print __LINE__;exit; if ($this->_request->isPost() && !array_key_exists('search', $_POST)) { $insert = false; $update = false; $id; // print_r($this->_request->getPost());exit; if ($_POST['orgId'] != 0) { $id = $_POST['orgId']; $update = true; } $formData = $this->_request->getPost(); if ($businessForm->isValid($formData)) { $uploadedData = $businessForm->getValues(); //print_r($uploadedData);exit; foreach ($_POST as $value => $t) { if (stristr($value, 'region')) { $uploadedData[$value] = 1; } if (stristr($value, 'subcat_')) { $uploadedData['category'][] = $t; } } $update ? FM_Components_Business::updateBusiness($uploadedData) : ($id = FM_Components_Business::insertBusiness($uploadedData)); if ($uploadedData['file']['name'] != '') { $name = $uploadedData['file']['name'] = '1' . '_' . time() . str_ireplace(array(' ', '_', '-', ','), '', strtolower($uploadedData['file']['name'])); $uploadedData['file']['type'] = 'image'; $fileHandler = new FM_Components_Util_UploadHandler($uploadedData['file']); $folder = $fileHandler->setFolder('logos'); if ($fileHandler->move()) { //exit; list($width, $height, $type, $attr) = getimagesize($_SERVER['DOCUMENT_ROOT'] . $folder . '/' . $name); //if($width > $_POST['width'] || $height > $_POST['height']) { // print '0'; // exit; //} $insertData['fileName'] = $name; $insertData['width'] = $width; $insertData['height'] = $height; $insertData['type'] = 'LG'; $insertData['active'] = '1'; //print (FM_Components_Util_Logo::hasRow($id)) ? 'yes' : 'no'; if (!FM_Components_Util_Logo::hasRow($id)) { $insertData['orgId'] = $id; } FM_Components_Util_Logo::hasRow($id) ? FM_Components_Util_Logo::updateBanner(array('orgId' => $id), $insertData) : FM_Components_Util_Logo::insert($insertData); } } if ($uploadedData['banner']['name'] != '') { $name = $uploadedData['banner']['name'] = '1' . '_' . time() . str_ireplace(array(' ', '_', '-', ','), '', strtolower($uploadedData['banner']['name'])); $uploadedData['file']['type'] = 'image'; $fileHandler = new FM_Components_Util_UploadHandler($uploadedData['banner']); $folder = $fileHandler->setFolder('logos'); if ($fileHandler->move()) { list($width, $height, $type, $attr) = getimagesize($_SERVER['DOCUMENT_ROOT'] . $folder . '/' . $name); $insertData['fileName'] = $name; $insertData['width'] = $width; $insertData['height'] = $height; $insertData['type'] = 'LG'; $insertData['active'] = '1'; if (!FM_Components_Util_MiniwebBanner::hasRow($id)) { $insertData['orgId'] = $id; } FM_Components_Util_MiniwebBanner::hasRow($id) ? FM_Components_Util_MiniwebBanner::updateBanner(array('orgId' => $id), $insertData) : FM_Components_Util_MiniwebBanner::insert($insertData); } } if ($uploadedData['icon']['name'] != '') { $name = $uploadedData['icon']['name'] = '1' . '_' . time() . str_ireplace(array(' ', '_', '-', ','), '', strtolower($uploadedData['icon']['name'])); $uploadedData['file']['type'] = 'image'; $fileHandler = new FM_Components_Util_UploadHandler($uploadedData['icon']); $folder = $fileHandler->setFolder('icons'); if ($fileHandler->move()) { list($width, $height, $type, $attr) = getimagesize($_SERVER['DOCUMENT_ROOT'] . $folder . '/' . $name); $insertData['fileName'] = $name; $insertData['width'] = $width; $insertData['height'] = $height; $insertData['type'] = 'LG'; $insertData['active'] = '1'; if (!FM_Components_Util_Icon::hasRow($id)) { $insertData['orgId'] = $id; } FM_Components_Util_Icon::hasRow($id) ? FM_Components_Util_Icon::updateIcon(array('orgId' => $id), $insertData) : FM_Components_Util_Icon::insert($insertData); } } $this->_redirect('/root/addbusiness/' . $this->_getParam('category')); } else { $this->view->error = true; } } } }