Example #1
0
 public function dynamicFormat($value)
 {
     if (is_numeric($value)) {
         if (strpos($value, ".") !== false) {
             return number_format($value, 2, ',', '.');
         }
         if (strlen($value) > 10) {
             return $this->view->formater(array())->cnpj($value);
         }
     } else {
         $dateFormats = array('Y-m-d' => 'd/m/Y', 'Y-m-d H:i:s' => 'd/m/Y H:i');
         $format = get_date_format($value, $dateFormats);
         if ($format) {
             return date($format, strtotime($value));
         }
     }
     return $this->view->escape($value);
 }
Example #2
0
function _unadcalendar_add_events($v, $clientId, $events, $calendarId, $cs, $email)
{
    $response = array();
    $location = "UNAD - " . get_course_by_code(JSON_COUSER, $cs);
    $n = 0;
    foreach ($events as $data) {
        $inf = array();
        if (count($data) < 5) {
            continue;
        }
        for ($i = count($data) - 7 - 1; $i < count($data); $i++) {
            if ($i >= 0) {
                $inf[] = $data[$i];
            }
        }
        $summary = $cs . ' - ' . $inf[0] . ' Valor: ' . $inf[4];
        $description = $inf[1] . "\n";
        $description .= "Valor de la actividad: " . $inf[4];
        $dataTimeStart = date("Y-m-d", get_date_format($inf[2])) . "T12:00:00.000-05:00";
        $dataTimeEnd = date("Y-m-d", get_date_format($inf[3])) . "T23:55:55.000-05:00";
        //inserta un envento al calendario
        $rqEvent = google_calendar_add_event($v, $clientId, $calendarId, $summary, $description, $location, $dataTimeStart, $dataTimeEnd, $email)->body();
        $rqEvent = json_decode($rqEvent);
        if ($rqEvent->status) {
            //si el evento fue insertado con exito
            $response[$n]['description'] = $rqEvent->event->description;
            $response[$n]['htmlLink'] = $rqEvent->event->htmlLink;
            $response[$n]['summary'] = $rqEvent->event->summary;
            $response[$n]['start'] = $rqEvent->event->start;
            $response[$n]['end'] = $rqEvent->event->end;
            $response[$n]['id'] = $rqEvent->event->id;
            $n++;
        }
    }
    return $response;
}
Example #3
0
    private function __construct_all()
    {
        global $objLogin;
        $this->params = array();
        if (isset($_POST['website_url'])) {
            $website_url = prepare_input($_POST['website_url'], false, 'medium');
            if (preg_match('/www./i', $website_url) && !preg_match('/http:/i', $website_url)) {
                $website_url = 'http://' . $website_url;
            }
            $this->params['website_url'] = $website_url;
        }
        if (isset($_POST['listing_location_id'])) {
            $this->params['listing_location_id'] = prepare_input($_POST['listing_location_id']);
        }
        if (isset($_POST['listing_sub_location_id'])) {
            $this->params['listing_sub_location_id'] = prepare_input($_POST['listing_sub_location_id']);
        }
        if (isset($_POST['business_email'])) {
            $this->params['business_email'] = prepare_input($_POST['business_email']);
        }
        if (isset($_POST['business_phone'])) {
            $this->params['business_phone'] = prepare_input($_POST['business_phone']);
        }
        if (isset($_POST['business_fax'])) {
            $this->params['business_fax'] = prepare_input($_POST['business_fax']);
        }
        if (isset($_POST['priority_order'])) {
            $this->params['priority_order'] = prepare_input($_POST['priority_order']);
        }
        if (isset($_POST['is_featured'])) {
            $this->params['is_featured'] = (int) $_POST['is_featured'];
        } else {
            $this->params['is_featured'] = '0';
        }
        if (isset($_POST['is_published'])) {
            $this->params['is_published'] = (int) $_POST['is_published'];
        } else {
            $this->params['is_published'] = '0';
        }
        if (isset($_POST['is_approved'])) {
            $this->params['is_approved'] = prepare_input($_POST['is_approved']);
        }
        if (isset($_POST['access_level'])) {
            $this->params['access_level'] = prepare_input($_POST['access_level']);
        }
        if (isset($_POST['date_published'])) {
            $this->params['date_published'] = prepare_input($_POST['date_published']);
        }
        if (isset($_POST['customer_id'])) {
            $this->params['customer_id'] = (int) $_POST['customer_id'];
        }
        if (isset($_POST['map_code'])) {
            $this->params['map_code'] = prepare_input($_POST['map_code'], false, 'low');
        }
        if (isset($_POST['video_url'])) {
            $this->params['video_url'] = prepare_input($_POST['video_url'], false, 'low');
        }
        if (isset($_POST['keywords'])) {
            $this->params['keywords'] = implode(',', array_map('trim', explode(',', prepare_input($_POST['keywords']))));
        }
        if (isset($_POST['advertise_plan_id'])) {
            $this->params['advertise_plan_id'] = prepare_input($_POST['advertise_plan_id']);
        }
        ///$this->params['language_id'] 	= MicroGrid::GetParameter('language_id');
        $rid = MicroGrid::GetParameter('rid');
        $action = MicroGrid::GetParameter('action');
        $operation = MicroGrid::GetParameter('operation');
        $filter_by_cid = MicroGrid::GetParameter('filter_by_cid', false);
        $payments_module = Modules::IsModuleInstalled('payments') && ModulesSettings::Get('payments', 'is_active') == 'yes' ? true : false;
        $watermark = ModulesSettings::Get('listings', 'watermark') == 'yes' ? true : false;
        $watermark_text = ModulesSettings::Get('listings', 'watermark_text');
        if ($action != 'view') {
            $listings_info = self::GetListingInfo($rid);
        }
        ## for images
        if (isset($_POST['image_file'])) {
            $this->params['image_file'] = prepare_input($_POST['image_file']);
        } else {
            if (isset($_FILES['image_file']['name']) && $_FILES['image_file']['name'] != '') {
                // nothing
            } else {
                if (self::GetParameter('action') == 'create') {
                    $this->params['image_file'] = '';
                }
            }
        }
        if ($payments_module) {
            $listings_count = $objLogin->GetAvailableListings();
        } else {
            $listings_count = -1;
        }
        $this->primaryKey = 'id';
        $this->tableName = TABLE_LISTINGS;
        $this->dataSet = array();
        $this->error = '';
        $this->formActionURL = 'index.php?' . ($objLogin->GetLoggedType() == 'customer' ? 'customer=my_listings' : 'admin=mod_listings_management');
        $categoriesActionURL = 'index.php?' . ($objLogin->GetLoggedType() == 'customer' ? 'customer=listings_categories' : 'admin=mod_listings_categories');
        $this->actions = array('add' => $objLogin->GetLoggedType() == 'customer' && $listings_count == 0 ? false : true, 'edit' => true, 'details' => true, 'delete' => true);
        $this->actionIcons = true;
        $this->allowRefresh = true;
        $this->allowTopButtons = true;
        $this->advertisePlanID = '0';
        $this->accessLevel = '';
        $this->isApproved = 0;
        $this->allowLanguages = false;
        //$this->languageId  	=  '';
        $default_lang = $objLogin->GetLoggedType() == 'customer' ? Languages::GetDefaultLang() : $objLogin->GetPreferredLang();
        $is_expired = false;
        if ($action == 'edit' && $action == 'details') {
            $is_expired = $listings_info['finish_publishing'] == '0000-00-00 00:00:00' || $listings_info['finish_publishing'] > date('Y-m-d H:i:s') ? false : true;
        }
        $this->WHERE_CLAUSE = 'WHERE ld.language_id = \'' . $default_lang . '\'';
        if ($operation != 'reset_filtering' && !empty($filter_by_cid)) {
            $this->WHERE_CLAUSE .= ' AND l.id IN (SELECT lc.listing_id FROM ' . TABLE_LISTINGS_CATEGORIES . ' lc WHERE lc.category_id = ' . (int) $filter_by_cid . ')';
        }
        $this->ORDER_CLAUSE = 'ORDER BY l.date_published ASC';
        $this->isAlterColorsAllowed = true;
        $this->isPagingAllowed = true;
        $this->pageSize = 20;
        $this->isSortingAllowed = true;
        $this->isExportingAllowed = $objLogin->IsLoggedInAsAdmin() ? true : false;
        $this->arrExportingTypes = array('csv' => true);
        // prepare access levels array
        $arr_access_levels = array('public' => _PUBLIC, 'registered' => _REGISTERED);
        // prepare featured array
        $arr_featured = array('0' => _NO, '1' => _YES);
        // prepare published array
        $arr_published = array('0' => _NO, '1' => _YES);
        // prepare advertise plans array
        $arr_advertise_plans = array();
        $total_plans = AdvertisePlans::GetAllPlans();
        foreach ($total_plans[0] as $key => $val) {
            $arr_advertise_plans[$val['id']] = $val['plan_name'];
        }
        if ($payments_module) {
            $arr_customer_advertise_plans = array();
            if ($objLogin->IsLoggedInAsCustomer()) {
                $plans = $objLogin->GetCustomerPlans();
                foreach ($plans as $key => $val) {
                    $arr_customer_advertise_plans[$val['id']] = $val['name'] . ' (' . $val['count'] . ' ' . _LISTINGS . ')';
                }
            }
        }
        // prepare categories array
        $objCategories = Categories::Instance();
        $total_categories = $objCategories->GetAllExistingCategories();
        $arr_categories = array();
        foreach ($total_categories as $key => $val) {
            if ($val['level'] == '1') {
                $arr_categories[$val['id']] = $val['name'];
            } else {
                if ($val['level'] == '2') {
                    $arr_categories[$val['id']] = '&nbsp;&nbsp;&bull; ' . $val['name'];
                } else {
                    if ($val['level'] == '3') {
                        $arr_categories[$val['id']] = '&nbsp;&nbsp;&nbsp;&nbsp;:: ' . $val['name'];
                    }
                }
            }
        }
        $datetime_format = get_datetime_format();
        $date_format = get_date_format();
        $arr_locations = array();
        $arr_sub_locations = array();
        if ($action != 'view') {
            // prepare array for location
            $total_locations = ListingsLocations::GetAllLocations('name ASC');
            foreach ($total_locations[0] as $key => $val) {
                $arr_locations[$val['id']] = $val['name'];
            }
            if ($action != 'edit' && $action != 'details') {
                // prepare array for sub-location
                $listing_location_id = (int) MicroGrid::GetParameter('listing_location_id', false);
                $total_sub_locations = ListingsSubLocations::GetAllSubLocations($listing_location_id, 'name ASC');
                foreach ($total_sub_locations[0] as $key => $val) {
                    $arr_sub_locations[$val['id']] = $val['name'];
                }
            }
        }
        // define filtering fields
        $this->isFilteringAllowed = true;
        $this->arrFilteringFields = array(_NAME => array('table' => 'ld', 'field' => 'business_name', 'type' => 'text', 'sign' => 'like%', 'width' => '110px'), _CATEGORY => array('table' => 'c', 'field' => 'id', 'type' => 'dropdownlist', 'source' => $arr_categories, 'sign' => '=', 'width' => '', 'visible' => $objLogin->IsLoggedInAsAdmin() ? true : false, 'custom_handler' => true), _FEATURED => array('table' => 'l', 'field' => 'is_featured', 'type' => 'dropdownlist', 'source' => $arr_featured, 'sign' => '=', 'width' => '', 'visible' => $objLogin->IsLoggedInAsAdmin() ? true : false), _PUBLISHED => array('table' => 'l', 'field' => 'is_published', 'type' => 'dropdownlist', 'source' => $arr_published, 'sign' => '=', 'width' => ''));
        // retrieve pre-moderation settings
        $pre_moderation_allow = ModulesSettings::Get('listings', 'pre_moderation_allow') == 'yes' ? true : false;
        ///////////////////////////////////////////////////////////////////////////////
        // 1. prepare translation fields array
        $this->arrTranslations = $this->PrepareTranslateFields(array('business_name', 'business_address', 'business_description'));
        ///////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////
        // 2. prepare translations array for edit/detail modes
        $sql_translation_description = $this->PrepareTranslateSql(TABLE_LISTINGS_DESCRIPTION, 'listing_id', array('business_name', 'business_address', 'business_description'));
        ///////////////////////////////////////////////////////////////////////////////
        // retrieve default priority order for new record
        $default_priority_order = '';
        if (self::GetParameter('action') == 'add') {
            $default_priority_order = $this->GetMaxOrder('priority_order', 9999);
        }
        // get plan features
        $advertise_plan_id = '';
        if ($action == 'add' || $action == 'create') {
            $advertise_plan_id = MicroGrid::GetParameter('advertise_plan_id', false);
        } else {
            if (in_array($action, array('details', 'edit', 'update'))) {
                // 1st time
                if (MicroGrid::GetParameter('advertise_plan_id', false)) {
                    $advertise_plan_id = MicroGrid::GetParameter('advertise_plan_id', false);
                } else {
                    $advertise_plan_id = $listings_info['advertise_plan_id'];
                }
            }
        }
        if (empty($advertise_plan_id)) {
            $advertise_plan_id = 1;
        }
        $advertise_plan_info = AdvertisePlans::GetPlanInfo($advertise_plan_id);
        // print_r($advertise_plan_info);
        $bpf_business_name = $advertise_plan_info[0]['business_name'];
        $bpf_business_description = $advertise_plan_info[0]['business_description'];
        $bpf_address = $advertise_plan_info[0]['address'];
        $bpf_logo = $advertise_plan_info[0]['logo'];
        $bpf_images_count = $advertise_plan_info[0]['images_count'];
        $bpf_phone = $advertise_plan_info[0]['phone'];
        $bpf_map = $advertise_plan_info[0]['map'];
        $bpf_video_link = $advertise_plan_info[0]['video_link'];
        $this->bpf_keywords_count = (int) $advertise_plan_info[0]['keywords_count'];
        // not needed to be inserted: inquiries_count, inquiries_count/per month, rating_button
        //----------------------------------------------------------------------
        // VIEW MODE
        //----------------------------------------------------------------------
        $this->VIEW_MODE_SQL = 'SELECT l.' . $this->primaryKey . ',
		                            l.customer_id,
									l.image_file,
									l.image_file_thumb,
									l.website_url,
									l.business_email,
									l.business_phone,
									l.business_fax,
									l.priority_order,
									l.access_level,
									l.is_featured,
									l.advertise_plan_id,
									IF(
										l.finish_publishing = "0000-00-00 00:00:00",
										"- ' . _NEVER . ' -",
										IF(l.finish_publishing < \'' . date('Y-m-d H:i:s') . '\', "<span class=no>' . _EXPIRED . '</span>", l.finish_publishing)
									) as finish_publishing,
									CONCAT("<img src=\\"images/", IF(l.is_published, "published_g.gif", "published_x.gif"), "\\" alt=\\"\\" />") as mod_is_published,
									CONCAT("<img src=\\"images/", IF(l.is_approved, "published_g.gif", "waiting.gif"), "\\" alt=\\"\\" />") as mod_is_approved,
									ld.business_name,
									IF(l.customer_id = 0, \'Admin\', cust.user_name) as customer_username,
									CONCAT("[ ' . _CATEGORIES . ' ]", " (", (SELECT COUNT(*) FROM ' . TABLE_LISTINGS_CATEGORIES . ' lc WHERE lc.listing_id = l.id), ")") as link_categories
								FROM ' . $this->tableName . ' l
								    ' . ($objLogin->GetLoggedType() == 'customer' ? 'INNER JOIN ' . TABLE_CUSTOMERS . ' cust ON (l.customer_id = cust.id AND l.customer_id=' . (int) $objLogin->GetLoggedID() . ')' : 'LEFT OUTER JOIN ' . TABLE_CUSTOMERS . ' cust ON (l.customer_id = cust.id)') . '
									LEFT OUTER JOIN ' . TABLE_LISTINGS_DESCRIPTION . ' ld ON (l.id = ld.listing_id AND ld.language_id = \'' . $default_lang . '\')';
        // define view mode fields
        $this->arrViewModeFields = array('image_file_thumb' => array('title' => _IMAGE, 'type' => 'image', 'sortable' => false, 'align' => 'left', 'width' => '64px', 'image_width' => '50px', 'image_height' => '30px', 'target' => 'images/listings/', 'no_image' => 'no_image.png'), 'business_name' => array('title' => _NAME, 'type' => $objLogin->GetLoggedType() == 'customer' ? 'link' : 'label', 'align' => 'left', 'width' => '200px', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'tooltip' => '', 'maxlength' => '45', 'format' => '', 'format_parameter' => '', 'href' => 'index.php?page=listing&lid={id}', 'target' => '_new'), 'advertise_plan_id' => array('title' => _ADVERTISE_PLAN, 'type' => 'enum', 'align' => 'center', 'width' => '90px', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'source' => $arr_advertise_plans), 'customer_username' => array('title' => _CUSTOMER, 'type' => 'label', 'align' => 'center', 'width' => '', 'visible' => $objLogin->IsLoggedInAsAdmin() ? true : false), 'access_level' => array('title' => _ACCESS, 'type' => 'enum', 'align' => 'center', 'width' => '70px', 'sortable' => true, 'nowrap' => '', 'source' => $arr_access_levels, 'visible' => $objLogin->IsLoggedInAsAdmin() ? true : false), 'mod_is_published' => array('title' => _PUBLISHED, 'type' => 'label', 'align' => 'center', 'width' => '70px', 'visible' => $objLogin->IsLoggedInAsAdmin()), 'mod_is_approved' => array('title' => _STATUS, 'type' => 'label', 'align' => 'center', 'width' => '80px', 'visible' => $objLogin->IsLoggedInAsCustomer()), 'finish_publishing' => array('title' => _FINISH_PUBLISHING, 'type' => 'label', 'align' => 'center', 'width' => '90px', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'tooltip' => '', 'maxlength' => '', 'format' => 'date', 'format_parameter' => $date_format), 'link_categories' => array('title' => '', 'type' => 'link', 'align' => 'center', 'width' => '115px', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'tooltip' => '', 'maxlength' => '', 'format' => '', 'format_parameter' => '', 'href' => $categoriesActionURL . '&listing_id={id}', 'target' => ''), 'priority_order' => array('title' => _ORDER, 'type' => 'label', 'align' => 'center', 'width' => '60px', 'movable' => true, 'visible' => $objLogin->IsLoggedInAsAdmin() ? true : false), 'id' => array('title' => 'ID', 'type' => 'label', 'align' => 'center', 'width' => '50px'));
        //----------------------------------------------------------------------
        // ADD MODE
        //----------------------------------------------------------------------
        // define add mode fields
        $this->arrAddModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'advertise_plan_id' => array('title' => _ADVERTISE_PLAN, 'type' => 'enum', 'width' => '', 'required' => true, 'readonly' => false, 'default' => '', 'source' => $objLogin->IsLoggedInAsAdmin() ? $arr_advertise_plans : $arr_customer_advertise_plans, 'default_option' => '', 'unique' => false, 'javascript_event' => 'onchange="appChangePlan(\'' . $this->tableName . '\')"', 'visible' => $payments_module), 'listing_location_id' => array('title' => _LOCATION, 'type' => 'enum', 'width' => '', 'source' => $arr_locations, 'required' => true, 'default' => '', 'javascript_event' => 'onchange="appRefillLocations(\'' . $this->tableName . '\')"'), 'listing_sub_location_id' => array('title' => _SUB_LOCATION, 'type' => 'enum', 'width' => '', 'source' => $arr_sub_locations, 'required' => true, 'default' => ''), 'website_url' => array('title' => _WEBSITE_URL . ' (http://)', 'type' => 'textbox', 'width' => '270px', 'required' => false, 'readonly' => false, 'validation_type' => 'text', 'maxlength' => '255'), 'business_email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'default' => '', 'readonly' => false, 'validation_type' => 'email', 'maxlength' => '75'), 'date_published' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => $pre_moderation_allow && $objLogin->GetLoggedType() == 'customer' ? '0000-00-00 00:00:00' : date('Y-m-d H:i:s')), 'customer_id' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => $objLogin->GetLoggedType() == 'customer' ? $objLogin->GetLoggedID() : '0')));
        if ($bpf_phone) {
            $this->arrAddModeFields['separator_general']['business_phone'] = array('title' => _PHONE, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'default' => '', 'readonly' => false, 'validation_type' => '', 'maxlength' => '32');
            $this->arrAddModeFields['separator_general']['business_fax'] = array('title' => _FAX, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'default' => '', 'readonly' => false, 'validation_type' => '', 'maxlength' => '32');
        }
        if ($bpf_video_link) {
            $this->arrAddModeFields['separator_general']['video_url'] = array('title' => _VIDEO, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'default' => '', 'readonly' => false, 'validation_type' => '', 'maxlength' => '32');
        }
        if ($this->bpf_keywords_count) {
            $this->arrAddModeFields['separator_general']['keywords'] = array('title' => _KEYWORDS, 'type' => 'textarea', 'required' => false, 'width' => '480px', 'height' => '58px', 'editor_type' => 'simple', 'readonly' => false, 'default' => '', 'validation_type' => '', 'validation_maxlength' => '1024', 'unique' => false);
        } else {
            $this->arrAddModeFields['separator_general']['keywords'] = array('title' => '', 'type' => 'hidden', 'required' => false, 'readonly' => false, 'default' => '');
        }
        if ($bpf_logo) {
            $this->arrAddModeFields['separator_gallery']['separator_info'] = array('legend' => _GALLERY);
            $this->arrAddModeFields['separator_gallery']['image_file'] = array('title' => _LOGO, 'type' => 'image', 'width' => '210px', 'required' => false, 'readonly' => false, 'target' => 'images/listings/', 'no_image' => '', 'image_width' => '150px', 'image_height' => '120px', 'random_name' => 'true', 'unique' => false, 'thumbnail_create' => true, 'thumbnail_field' => 'image_file_thumb', 'thumbnail_width' => '150px', 'thumbnail_height' => '120px', 'file_maxsize' => '200k');
            for ($i = 1; $i <= $bpf_images_count; $i++) {
                $this->arrAddModeFields['separator_gallery']['image_' . $i] = array('title' => _IMAGE . ' #' . $i, 'type' => 'image', 'width' => '210px', 'required' => false, 'readonly' => false, 'target' => 'images/listings/', 'no_image' => '', 'image_width' => '150px', 'image_height' => '120px', 'random_name' => 'true', 'unique' => false, 'thumbnail_create' => true, 'thumbnail_field' => 'image_' . $i . '_thumb', 'thumbnail_width' => '150px', 'thumbnail_height' => '120px', 'file_maxsize' => '500k', 'watermark' => $watermark, 'watermark_text' => $watermark_text);
            }
        }
        if ($bpf_map) {
            $this->arrAddModeFields['separator_map']['separator_info'] = array('legend' => _MAP_CODE);
            $this->arrAddModeFields['separator_map']['map_code'] = array('title' => _MAP_CODE, 'type' => 'textarea', 'required' => false, 'width' => '480px', 'height' => '100px', 'editor_type' => 'simple', 'readonly' => false, 'default' => '', 'validation_type' => '', 'validation_maxlength' => '1024', 'unique' => false);
        } else {
            $this->arrAddModeFields['separator_general']['map_code'] = array('title' => '', 'type' => 'hidden', 'required' => false, 'readonly' => false, 'default' => '');
        }
        if ($objLogin->IsLoggedInAsAdmin()) {
            $this->arrAddModeFields['separator_general']['is_published'] = array('title' => _PUBLISHED, 'type' => 'checkbox', 'readonly' => false, 'default' => '1', 'true_value' => '1', 'false_value' => '0');
            $this->arrAddModeFields['separator_general']['is_approved'] = array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => '1');
            $this->arrAddModeFields['separator_general']['priority_order'] = array('title' => _ORDER, 'type' => 'textbox', 'width' => '50px', 'required' => true, 'default' => $default_priority_order, 'readonly' => false, 'validation_type' => 'numeric|positive', 'maxlength' => '4');
            $this->arrAddModeFields['separator_general']['is_featured'] = array('title' => _FEATURED, 'type' => 'checkbox', 'readonly' => false, 'default' => '1', 'true_value' => '1', 'false_value' => '0');
            $this->arrAddModeFields['separator_general']['access_level'] = array('title' => _ACCESSIBLE_BY, 'type' => 'enum', 'width' => '', 'required' => true, 'readonly' => false, 'default' => 'public', 'source' => $arr_access_levels, 'default_option' => '', 'unique' => false, 'javascript_event' => '');
        } else {
            if ($pre_moderation_allow) {
                $this->arrAddModeFields['separator_general']['is_published'] = array('type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => '0');
                $this->arrAddModeFields['separator_general']['is_approved'] = array('type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => '0');
                $this->arrAddModeFields['separator_general']['access_level'] = array('type' => 'hidden', 'required' => true, 'default' => 'public');
            } else {
                $this->arrAddModeFields['separator_general']['is_published'] = array('type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => '1');
                $this->arrAddModeFields['separator_general']['is_approved'] = array('type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => '1');
            }
        }
        //----------------------------------------------------------------------
        // EDIT MODE
        //----------------------------------------------------------------------
        // define edit mode fields
        $this->EDIT_MODE_SQL = 'SELECT
								l.*,
								' . $sql_translation_description . '
								IF(
									l.finish_publishing = \'0000-00-00 00:00:00\',
									"- ' . _NEVER . ' -",
									IF(l.finish_publishing < \'' . date('Y-m-d H:i:s') . '\', \'<span class=no>' . _EXPIRED . '</span>\', l.finish_publishing)
								) as finish_publishing,								
								CONCAT("<img src=\\"images/listings/", l.image_file_thumb, "\\" alt=\\"\\" width=\\"40px\\ height=\\"30px\\" />") as my_image_file,
								IF(l.is_featured, \'' . _YES . '\', \'' . _NO . '\') as mod_is_featured,
								IF(l.is_published, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as mod_is_published,
								IF(l.is_approved, "<span class=yes>' . _APPROVED . '</span>", "<span class=no>' . _PENDING . '</span>") as mod_is_approved
							FROM ' . $this->tableName . ' l
								' . ($objLogin->GetLoggedType() == 'customer' ? 'INNER JOIN ' . TABLE_CUSTOMERS . ' cust ON (l.customer_id = cust.id AND l.customer_id=' . (int) $objLogin->GetLoggedID() . ')' : '') . '
							WHERE l.' . $this->primaryKey . ' = _RID_';
        // define edit mode fields
        $this->arrEditModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'advertise_plan_id' => array('title' => _ADVERTISE_PLAN, 'type' => 'enum', 'width' => '', 'required' => true, 'readonly' => $objLogin->IsLoggedInAsAdmin() ? $is_expired ? true : false : true, 'default' => '', 'source' => $arr_advertise_plans, 'default_option' => '', 'unique' => false, 'javascript_event' => 'onchange="appChangePlan(\'' . $this->tableName . '\')"', 'visible' => $payments_module), 'listing_location_id' => array('title' => _LOCATION, 'type' => 'enum', 'width' => '', 'source' => $arr_locations, 'required' => true, 'javascript_event' => 'onchange="appRefillLocations(\'' . $this->tableName . '\')"'), 'listing_sub_location_id' => array('title' => _SUB_LOCATION, 'type' => 'enum', 'width' => '', 'source' => $arr_sub_locations, 'required' => true), 'website_url' => array('title' => _WEBSITE_URL . ' (http://)', 'type' => 'textbox', 'width' => '270px', 'required' => false, 'readonly' => false, 'validation_type' => 'text', 'maxlength' => '255'), 'business_email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'default' => '', 'readonly' => false, 'validation_type' => 'email', 'maxlength' => '75')));
        if ($bpf_phone) {
            $this->arrEditModeFields['separator_general']['business_phone'] = array('title' => _PHONE, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'default' => '', 'readonly' => false, 'validation_type' => '', 'maxlength' => '32');
            $this->arrEditModeFields['separator_general']['business_fax'] = array('title' => _FAX, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'default' => '', 'readonly' => false, 'validation_type' => '', 'maxlength' => '32');
        }
        if ($bpf_video_link) {
            $this->arrEditModeFields['separator_general']['video_url'] = array('title' => _VIDEO, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'default' => '', 'readonly' => false, 'validation_type' => '', 'maxlength' => '32');
        }
        if ($this->bpf_keywords_count) {
            $this->arrEditModeFields['separator_general']['keywords'] = array('title' => _KEYWORDS, 'type' => 'textarea', 'required' => false, 'width' => '480px', 'height' => '58px', 'editor_type' => 'simple', 'readonly' => false, 'default' => '', 'validation_type' => '', 'validation_maxlength' => '1024', 'unique' => false);
        }
        if ($bpf_logo) {
            $this->arrEditModeFields['separator_gallery']['separator_info'] = array('legend' => _GALLERY);
            $this->arrEditModeFields['separator_gallery']['image_file'] = array('title' => _LOGO, 'type' => 'image', 'width' => '210px', 'required' => false, 'readonly' => false, 'target' => 'images/listings/', 'no_image' => '', 'image_width' => '150px', 'image_height' => '120px', 'random_name' => 'true', 'unique' => false, 'thumbnail_create' => true, 'thumbnail_field' => 'image_file_thumb', 'thumbnail_width' => '150px', 'thumbnail_height' => '120px', 'file_maxsize' => '200k');
            for ($i = 1; $i <= $bpf_images_count; $i++) {
                $this->arrEditModeFields['separator_gallery']['image_' . $i] = array('title' => _IMAGE . ' #' . $i, 'type' => 'image', 'width' => '210px', 'required' => false, 'readonly' => false, 'target' => 'images/listings/', 'no_image' => '', 'image_width' => '150px', 'image_height' => '120px', 'random_name' => 'true', 'unique' => false, 'thumbnail_create' => true, 'thumbnail_field' => 'image_' . $i . '_thumb', 'thumbnail_width' => '150px', 'thumbnail_height' => '120px', 'file_maxsize' => '500k', 'watermark' => $watermark, 'watermark_text' => $watermark_text);
            }
        }
        if ($bpf_map) {
            $this->arrEditModeFields['separator_map']['separator_info'] = array('legend' => _MAP_CODE);
            $this->arrEditModeFields['separator_map']['map_code'] = array('title' => _MAP_CODE, 'type' => 'textarea', 'required' => false, 'width' => '480px', 'height' => '100px', 'editor_type' => 'simple', 'readonly' => false, 'default' => '', 'validation_type' => '', 'validation_maxlength' => '1024', 'unique' => false);
        }
        $this->arrEditModeFields['separator_general']['mod_is_approved'] = array('title' => _STATUS, 'type' => 'label');
        if ($objLogin->IsLoggedInAsAdmin()) {
            $this->arrEditModeFields['separator_general']['priority_order'] = array('title' => _ORDER, 'type' => 'textbox', 'width' => '50px', 'required' => true, 'readonly' => false, 'validation_type' => 'numeric|positive', 'maxlength' => '4');
            $this->arrEditModeFields['separator_general']['is_featured'] = array('title' => _FEATURED, 'type' => 'checkbox', 'readonly' => $is_expired ? true : false, 'true_value' => '1', 'false_value' => '0');
            ///$this->arrEditModeFields['separator_general']['date_published'] = array('title'=>_DATE_PUBLISHED, 'type'=>'hidden', 'required'=>true, 'readonly'=>false, 'default'=>date('Y-m-d H:i:s'));
            $this->arrEditModeFields['separator_general']['is_published'] = array('title' => _PUBLISHED, 'type' => 'checkbox', 'readonly' => $is_expired ? true : false, 'visible' => $is_expired ? false : true, 'true_value' => '1', 'false_value' => '0');
            $this->arrEditModeFields['separator_general']['access_level'] = array('title' => _ACCESSIBLE_BY, 'type' => 'enum', 'width' => '', 'required' => true, 'readonly' => $is_expired ? true : false, 'default' => 'public', 'source' => $arr_access_levels, 'default_option' => '', 'unique' => false, 'javascript_event' => '');
        }
        $this->arrEditModeFields['separator_general']['finish_publishing'] = array('title' => _FINISH_PUBLISHING, 'type' => 'label', 'format' => 'date', 'format_parameter' => $date_format);
        $this->arrEditModeFields['separator_general']['customer_id'] = array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => '');
        //----------------------------------------------------------------------
        // DETAILS MODE
        //----------------------------------------------------------------------
        $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL;
        $this->arrDetailsModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'advertise_plan_id' => array('title' => _ADVERTISE_PLAN, 'type' => 'enum', 'source' => $arr_advertise_plans, 'visible' => $payments_module), 'listing_location_id' => array('title' => _LOCATION, 'type' => 'enum', 'source' => $arr_locations), 'listing_sub_location_id' => array('title' => _SUB_LOCATION, 'type' => 'enum', 'source' => $arr_sub_locations), 'website_url' => array('title' => _WEBSITE_URL, 'type' => 'label'), 'business_email' => array('title' => _EMAIL_ADDRESS, 'type' => 'label'), 'mod_is_approved' => array('title' => _STATUS, 'type' => 'label'), 'mod_is_published' => array('title' => _PUBLISHED, 'type' => 'label'), 'date_published' => array('title' => _DATE_PUBLISHED, 'type' => 'datetime', 'format' => 'datetime', 'format_parameter' => $datetime_format)));
        if ($bpf_phone) {
            $this->arrDetailsModeFields['separator_general']['business_phone'] = array('title' => _PHONE, 'type' => 'label');
            $this->arrDetailsModeFields['separator_general']['business_fax'] = array('title' => _FAX, 'type' => 'label');
        }
        if ($bpf_video_link) {
            $this->arrDetailsModeFields['separator_general']['video_url'] = array('title' => _VIDEO, 'type' => 'label');
        }
        if ($this->bpf_keywords_count) {
            $this->arrDetailsModeFields['separator_general']['keywords'] = array('title' => _KEYWORDS, 'type' => 'label');
        }
        if ($bpf_logo) {
            $this->arrDetailsModeFields['separator_gallery']['separator_info'] = array('legend' => _GALLERY);
            $this->arrDetailsModeFields['separator_gallery']['image_file'] = array('title' => _LOGO, 'type' => 'image', 'target' => 'images/listings/', 'image_width' => '90px', 'image_height' => '80px', 'no_image' => 'no_image.png');
            for ($i = 1; $i <= $bpf_images_count; $i++) {
                $this->arrDetailsModeFields['separator_gallery']['image_' . $i] = array('title' => _IMAGE . ' #' . $i, 'type' => 'image', 'target' => 'images/listings/', 'image_width' => '90px', 'image_height' => '80px', 'no_image' => 'no_image.png');
            }
        }
        if ($bpf_map) {
            $this->arrDetailsModeFields['separator_map']['separator_info'] = array('legend' => _MAP_CODE);
            $this->arrDetailsModeFields['separator_map']['map_code'] = array('title' => _MAP_CODE, 'type' => 'html');
        }
        if ($objLogin->IsLoggedInAsAdmin()) {
            $this->arrDetailsModeFields['separator_general']['priority_order'] = array('title' => _ORDER, 'type' => 'label');
            $this->arrDetailsModeFields['separator_general']['mod_is_featured'] = array('title' => _FEATURED, 'type' => 'label');
            $this->arrDetailsModeFields['separator_general']['access_level'] = array('title' => _ACCESSIBLE_BY, 'type' => 'enum', 'source' => $arr_access_levels);
        }
        $this->arrDetailsModeFields['separator_general']['finish_publishing'] = array('title' => _FINISH_PUBLISHING, 'type' => 'label', 'format' => 'date', 'format_parameter' => $date_format);
        ///////////////////////////////////////////////////////////////////////////////
        // 3. add translation fields to all modes
        $arrTranslations = array();
        if ($bpf_business_name) {
            $arrTranslations['business_name'] = array('title' => _NAME, 'type' => 'textbox', 'required' => true, 'width' => '410px', 'maxlength' => '125');
        }
        if ($bpf_address) {
            $arrTranslations['business_address'] = array('title' => _ADDRESS, 'type' => 'textarea', 'required' => false, 'width' => '410px', 'height' => '50px', 'maxlength' => '255');
        }
        if ($bpf_business_description) {
            $arrTranslations['business_description'] = array('title' => _DESCRIPTION, 'type' => 'textarea', 'required' => false, 'width' => '410px', 'height' => '90px', 'maxlength' => '1024');
        }
        $this->AddTranslateToModes($this->arrTranslations, $arrTranslations);
        ///////////////////////////////////////////////////////////////////////////////
    }
Example #4
0
    function __construct()
    {
        parent::__construct();
        $this->params = array();
        if (isset($_POST['group_id'])) {
            $this->params['group_id'] = (int) prepare_input($_POST['group_id']);
        }
        if (isset($_POST['first_name'])) {
            $this->params['first_name'] = prepare_input($_POST['first_name']);
        }
        if (isset($_POST['last_name'])) {
            $this->params['last_name'] = prepare_input($_POST['last_name']);
        }
        if (isset($_POST['birth_date']) && $_POST['birth_date'] != '') {
            $this->params['birth_date'] = prepare_input($_POST['birth_date']);
        } else {
            $this->params['birth_date'] = '0000-00-00';
        }
        if (isset($_POST['company'])) {
            $this->params['company'] = prepare_input($_POST['company']);
        }
        if (isset($_POST['b_address'])) {
            $this->params['b_address'] = prepare_input($_POST['b_address']);
        }
        if (isset($_POST['b_address_2'])) {
            $this->params['b_address_2'] = prepare_input($_POST['b_address_2']);
        }
        if (isset($_POST['b_city'])) {
            $this->params['b_city'] = prepare_input($_POST['b_city']);
        }
        if (isset($_POST['b_state'])) {
            $this->params['b_state'] = prepare_input($_POST['b_state']);
        }
        if (isset($_POST['b_country'])) {
            $this->params['b_country'] = prepare_input($_POST['b_country']);
        }
        if (isset($_POST['b_zipcode'])) {
            $this->params['b_zipcode'] = prepare_input($_POST['b_zipcode']);
        }
        if (isset($_POST['phone'])) {
            $this->params['phone'] = prepare_input($_POST['phone']);
        }
        if (isset($_POST['fax'])) {
            $this->params['fax'] = prepare_input($_POST['fax']);
        }
        if (isset($_POST['email'])) {
            $this->params['email'] = prepare_input($_POST['email']);
        }
        if (isset($_POST['url'])) {
            $this->params['url'] = prepare_input($_POST['url'], false, 'medium');
        }
        if (isset($_POST['user_name'])) {
            $this->params['user_name'] = prepare_input($_POST['user_name']);
        }
        if (isset($_POST['user_password'])) {
            $this->params['user_password'] = prepare_input($_POST['user_password']);
        }
        if (isset($_POST['preferred_language'])) {
            $this->params['preferred_language'] = prepare_input($_POST['preferred_language']);
        }
        if (isset($_POST['date_created'])) {
            $this->params['date_created'] = prepare_input($_POST['date_created']);
        }
        if (isset($_POST['date_lastlogin'])) {
            $this->params['date_lastlogin'] = prepare_input($_POST['date_lastlogin']);
        }
        if (isset($_POST['registered_from_ip'])) {
            $this->params['registered_from_ip'] = prepare_input($_POST['registered_from_ip']);
        }
        if (isset($_POST['last_logged_ip'])) {
            $this->params['last_logged_ip'] = prepare_input($_POST['last_logged_ip']);
        }
        if (isset($_POST['email_notifications'])) {
            $this->params['email_notifications'] = prepare_input($_POST['email_notifications']);
        } else {
            $this->params['email_notifications'] = '0';
        }
        if (isset($_POST['notification_status_changed'])) {
            $this->params['notification_status_changed'] = prepare_input($_POST['notification_status_changed']);
        }
        if (isset($_POST['is_active'])) {
            $this->params['is_active'] = (int) $_POST['is_active'];
        } else {
            $this->params['is_active'] = '0';
        }
        if (isset($_POST['is_removed'])) {
            $this->params['is_removed'] = (int) $_POST['is_removed'];
        } else {
            $this->params['is_removed'] = '0';
        }
        if (isset($_POST['comments'])) {
            $this->params['comments'] = prepare_input($_POST['comments']);
        }
        if (isset($_POST['registration_code'])) {
            $this->params['registration_code'] = prepare_input($_POST['registration_code']);
        }
        if (isset($_POST['plan1_listings'])) {
            $this->params['plan1_listings'] = prepare_input($_POST['plan1_listings']);
        }
        if (isset($_POST['plan2_listings'])) {
            $this->params['plan2_listings'] = prepare_input($_POST['plan2_listings']);
        }
        if (isset($_POST['plan3_listings'])) {
            $this->params['plan3_listings'] = prepare_input($_POST['plan3_listings']);
        }
        if (isset($_POST['plan4_listings'])) {
            $this->params['plan4_listings'] = prepare_input($_POST['plan4_listings']);
        }
        $rid = MicroGrid::GetParameter('rid');
        $action = MicroGrid::GetParameter('action');
        $this->email_notifications = '';
        $this->user_password = '';
        $this->allow_adding_by_admin = ModulesSettings::Get('customers', 'allow_adding_by_admin');
        $this->allow_changing_password = ModulesSettings::Get('customers', 'password_changing_by_admin');
        $this->reg_confirmation = ModulesSettings::Get('customers', 'reg_confirmation');
        $allow_adding = $this->allow_adding_by_admin == 'yes' ? true : false;
        $this->primaryKey = 'id';
        $this->tableName = TABLE_CUSTOMERS;
        $this->dataSet = array();
        $this->error = '';
        ///$this->languageId  	= (isset($_REQUEST['language_id']) && $_REQUEST['language_id'] != '') ? $_REQUEST['language_id'] : Languages::GetDefaultLang();
        $this->formActionURL = 'index.php?admin=mod_customers_management';
        $this->actions = array('add' => $allow_adding, 'edit' => true, 'details' => true, 'delete' => true);
        $this->actionIcons = true;
        $this->allowRefresh = true;
        $this->allowTopButtons = true;
        $this->allowLanguages = false;
        $this->WHERE_CLAUSE = '';
        $this->ORDER_CLAUSE = 'ORDER BY id DESC';
        $this->isAlterColorsAllowed = true;
        $this->isPagingAllowed = true;
        $this->pageSize = 20;
        $this->isSortingAllowed = true;
        $total_countries = Countries::GetAllCountries('priority_order DESC, name ASC');
        $arr_countries = array();
        foreach ($total_countries[0] as $key => $val) {
            $arr_countries[$val['abbrv']] = $val['name'];
        }
        // prepare plans array
        $total_plans = AdvertisePlans::GetAllPlans();
        $arr_plans = array();
        foreach ($total_plans[0] as $key => $val) {
            $arr_plans[$val['id']] = $val['plan_name'];
        }
        // prepare groups array
        $total_groups = CustomerGroups::GetAllGroups();
        $arr_groups = array();
        foreach ($total_groups[0] as $key => $val) {
            $arr_groups[$val['id']] = $val['name'];
        }
        // prepare languages array
        $total_languages = Languages::GetAllActive();
        $arr_languages = array();
        foreach ($total_languages[0] as $key => $val) {
            $arr_languages[$val['abbreviation']] = $val['lang_name'];
        }
        $this->isFilteringAllowed = true;
        // define filtering fields
        $this->arrFilteringFields = array(_FIRST_NAME => array('table' => 'c', 'field' => 'first_name', 'type' => 'text', 'sign' => 'like%', 'width' => '80px'), _LAST_NAME => array('table' => 'c', 'field' => 'last_name', 'type' => 'text', 'sign' => 'like%', 'width' => '80px'), _EMAIL => array('table' => 'c', 'field' => 'email', 'type' => 'text', 'sign' => 'like%', 'width' => '90px'), _ACTIVE => array('table' => 'c', 'field' => 'is_active', 'type' => 'dropdownlist', 'source' => array('0' => _NO, '1' => _YES), 'sign' => '=', 'width' => '85px'), _GROUP => array('table' => 'c', 'field' => 'group_id', 'type' => 'dropdownlist', 'source' => $arr_groups, 'sign' => '=', 'width' => '85px'));
        $customer_ip = get_current_ip();
        $datetime_format = get_datetime_format();
        $date_format_view = get_date_format('view');
        $date_format_edit = get_date_format('edit');
        $default_plan_info = AdvertisePlans::GetDefaultPlanInfo();
        $default_plan_id = isset($default_plan_info['id']) ? (int) $default_plan_info['id'] : 0;
        $default_plan_lc = isset($default_plan_info['listings_count']) ? (int) $default_plan_info['listings_count'] : 0;
        //----------------------------------------------------------------------
        // VIEW MODE
        //----------------------------------------------------------------------
        $this->VIEW_MODE_SQL = 'SELECT
									c.' . $this->primaryKey . ',
		                            c.*,
									CONCAT(c.first_name, " ", c.last_name) as full_name,
									IF(c.is_active, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as customer_active,
									cg.name as group_name
								FROM ' . $this->tableName . ' c
									LEFT OUTER JOIN ' . TABLE_CUSTOMER_GROUPS . ' cg ON c.group_id = cg.id ';
        // define view mode fields
        $this->arrViewModeFields = array('full_name' => array('title' => _NAME, 'type' => 'label', 'align' => 'left', 'width' => '', 'maxlength' => '20'), 'user_name' => array('title' => _USERNAME, 'type' => 'label', 'align' => 'left', 'width' => '', 'maxlength' => '20'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'link', 'href' => 'mailto:{email}', 'align' => 'left', 'width' => '', 'maxlength' => '36'), 'b_country' => array('title' => _COUNTRY, 'type' => 'enum', 'align' => 'left', 'width' => '', 'sortable' => true, 'nowrap' => '', 'visible' => '', 'source' => $arr_countries), 'customer_active' => array('title' => _ACTIVE, 'type' => 'label', 'align' => 'center', 'width' => '90px'), 'group_name' => array('title' => _GROUP, 'type' => 'label', 'align' => 'left', 'width' => '90px'), 'id' => array('title' => 'ID', 'type' => 'label', 'align' => 'center', 'width' => '50px'));
        //----------------------------------------------------------------------
        // ADD MODE
        //----------------------------------------------------------------------
        // define add mode fields
        $this->arrAddModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'birth_date' => array('title' => _BIRTH_DATE, 'type' => 'date', 'width' => '210px', 'required' => false, 'readonly' => false, 'default' => '', 'validation_type' => 'date', 'unique' => false, 'visible' => true, 'min_year' => '90', 'max_year' => '0', 'format' => 'date', 'format_parameter' => $date_format_edit), 'url' => array('title' => _URL, 'type' => 'textbox', 'width' => '270px', 'required' => false, 'maxlength' => '255', 'validation_type' => 'text')), 'separator_2' => array('separator_info' => array('legend' => _BILLING_ADDRESS), 'company' => array('title' => _COMPANY, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '128', 'validation_type' => 'text'), 'b_address' => array('title' => _ADDRESS, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text'), 'b_address_2' => array('title' => _ADDRESS_2, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '64', 'validation_type' => 'text'), 'b_city' => array('title' => _CITY, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text'), 'b_zipcode' => array('title' => _ZIP_CODE, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'b_country' => array('title' => _COUNTRY, 'type' => 'enum', 'width' => '', 'source' => $arr_countries, 'required' => true), 'b_state' => array('title' => _STATE_PROVINCE, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text')), 'separator_3' => array('separator_info' => array('legend' => _CONTACT_INFORMATION), 'phone' => array('title' => _PHONE, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '32', 'validation_type' => 'text'), 'fax' => array('title' => _FAX, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '32', 'validation_type' => 'text'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '230px', 'required' => false, 'maxlength' => '70', 'validation_type' => 'email', 'unique' => true, 'autocomplete' => 'off')), 'separator_4' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USERNAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'validation_type' => 'text', 'maxlength' => '32', 'validation_minlength' => '4', 'readonly' => false, 'unique' => true), 'user_password' => array('title' => _PASSWORD, 'type' => 'password', 'width' => '210px', 'required' => true, 'validation_type' => 'password', 'maxlength' => '20', 'cryptography' => PASSWORDS_ENCRYPTION, 'cryptography_type' => PASSWORDS_ENCRYPTION_TYPE, 'aes_password' => PASSWORDS_ENCRYPT_KEY), 'group_id' => array('title' => _CUSTOMER_GROUP, 'type' => 'enum', 'required' => false, 'readonly' => false, 'width' => '', 'source' => $arr_groups), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'required' => true, 'readonly' => false, 'width' => '120px', 'default' => Application::Get('lang'), 'source' => $arr_languages)), 'separator_5' => array('separator_info' => array('legend' => _OTHER), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => date('Y-m-d H:i:s')), 'registered_from_ip' => array('title' => _REGISTERED_FROM_IP, 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $customer_ip), 'last_logged_ip' => array('title' => _LAST_LOGGED_IP, 'type' => 'hidden', 'width' => '210px', 'required' => false, 'default' => ''), 'email_notifications' => array('title' => _EMAIL_NOTIFICATION, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'default' => '1', 'true_value' => '1', 'false_value' => '0', 'unique' => false), 'is_removed' => array('title' => _REMOVED, 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => '0'), 'comments' => array('title' => _COMMENTS, 'type' => 'textarea', 'width' => '420px', 'height' => '70px', 'required' => false, 'readonly' => false, 'validation_type' => 'text', 'validation_maxlength' => '2048'), 'registration_code' => array('title' => _REGISTRATION_CODE, 'type' => 'hidden', 'width' => '210px', 'required' => false, 'default' => ''), 'plan1_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[1], 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $default_plan_id == '1' ? (int) $default_plan_lc : '0'), 'plan2_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[2], 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $default_plan_id == '2' ? (int) $default_plan_lc : '0'), 'plan3_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[3], 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $default_plan_id == '3' ? (int) $default_plan_lc : '0'), 'plan4_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[4], 'type' => 'hidden', 'width' => '210px', 'required' => true, 'default' => $default_plan_id == '4' ? (int) $default_plan_lc : '0')));
        //----------------------------------------------------------------------
        // EDIT MODE
        // * password field must be written directly in SQL!!!
        //----------------------------------------------------------------------
        $this->EDIT_MODE_SQL = 'SELECT
									' . $this->tableName . '.' . $this->primaryKey . ',
		                            ' . $this->tableName . '.*,
									' . $this->tableName . '.user_password,
									' . $this->tableName . '.date_created,
									' . $this->tableName . '.date_lastlogin,
									' . $this->tableName . '.notification_status_changed
								FROM ' . $this->tableName . '
								WHERE ' . $this->tableName . '.' . $this->primaryKey . ' = _RID_';
        // define edit mode fields
        $this->arrEditModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'birth_date' => array('title' => _BIRTH_DATE, 'type' => 'date', 'width' => '210px', 'required' => false, 'readonly' => false, 'default' => '', 'validation_type' => 'date', 'unique' => false, 'visible' => true, 'min_year' => '90', 'max_year' => '0', 'format' => 'date', 'format_parameter' => $date_format_edit), 'url' => array('title' => _URL, 'type' => 'textbox', 'width' => '270px', 'required' => false, 'maxlength' => '255', 'validation_type' => 'text')), 'separator_2' => array('separator_info' => array('legend' => _BILLING_ADDRESS), 'company' => array('title' => _COMPANY, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '128', 'validation_type' => 'text'), 'b_address' => array('title' => _ADDRESS, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text'), 'b_address_2' => array('title' => _ADDRESS_2, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '64', 'validation_type' => 'text'), 'b_city' => array('title' => _CITY, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '64', 'validation_type' => 'text'), 'b_zipcode' => array('title' => _ZIP_CODE, 'type' => 'textbox', 'width' => '210px', 'required' => true, 'maxlength' => '32', 'validation_type' => 'text'), 'b_country' => array('title' => _COUNTRY, 'type' => 'enum', 'width' => '', 'source' => $arr_countries, 'required' => true), 'b_state' => array('title' => _STATE_PROVINCE, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '64', 'validation_type' => 'text')), 'separator_3' => array('separator_info' => array('legend' => _CONTACT_INFORMATION), 'phone' => array('title' => _PHONE, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '32', 'validation_type' => 'text'), 'fax' => array('title' => _FAX, 'type' => 'textbox', 'width' => '210px', 'required' => false, 'maxlength' => '32', 'validation_type' => 'text'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'textbox', 'width' => '230px', 'required' => true, 'maxlength' => '70', 'readonly' => false, 'validation_type' => 'email', 'unique' => true, 'autocomplete' => 'off')), 'separator_4' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USERNAME, 'type' => 'label'), 'user_password' => array('title' => _PASSWORD, 'type' => 'password', 'width' => '210px', 'maxlength' => '20', 'required' => true, 'validation_type' => 'password', 'cryptography' => PASSWORDS_ENCRYPTION, 'cryptography_type' => PASSWORDS_ENCRYPTION_TYPE, 'aes_password' => PASSWORDS_ENCRYPT_KEY, 'visible' => $this->allow_changing_password == 'yes' ? true : false), 'group_id' => array('title' => _CUSTOMER_GROUP, 'type' => 'enum', 'required' => false, 'readonly' => false, 'width' => '', 'source' => $arr_groups), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'required' => true, 'readonly' => false, 'width' => '120px', 'source' => $arr_languages)), 'separator_5' => array('separator_info' => array('legend' => _OTHER), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'date_lastlogin' => array('title' => _LAST_LOGIN, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'registered_from_ip' => array('title' => _REGISTERED_FROM_IP, 'type' => 'label'), 'last_logged_ip' => array('title' => _LAST_LOGGED_IP, 'type' => 'label'), 'email_notifications' => array('title' => _EMAIL_NOTIFICATION, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0'), 'notification_status_changed' => array('title' => _NOTIFICATION_STATUS_CHANGED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0'), 'is_removed' => array('title' => _REMOVED, 'type' => 'checkbox', 'true_value' => '1', 'false_value' => '0'), 'comments' => array('title' => _COMMENTS, 'type' => 'textarea', 'width' => '420px', 'height' => '70px', 'required' => false, 'readonly' => false, 'validation_type' => 'text', 'validation_maxlength' => '2048'), 'registration_code' => array('title' => _REGISTRATION_CODE, 'type' => 'hidden', 'width' => '210px', 'required' => false, 'default' => '')), 'separator_6' => array('separator_info' => array('legend' => _LISTINGS), 'orders_count' => array('title' => _ORDERS_COUNT, 'type' => 'label'), 'plan1_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[1], 'type' => 'label'), 'plan2_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[2], 'type' => 'label'), 'plan3_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[3], 'type' => 'label'), 'plan4_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[4], 'type' => 'label')));
        //----------------------------------------------------------------------
        // DETAILS MODE
        //----------------------------------------------------------------------
        $this->DETAILS_MODE_SQL = 'SELECT
									c.' . $this->primaryKey . ',
		                            c.*,
									IF(c.email_notifications, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as email_notifications,
									IF(c.is_active, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as customer_active,
									IF(c.is_removed, "<span class=yes>' . _YES . '</span>", "<span class=no>' . _NO . '</span>") as customer_removed,
									c.date_created,
									c.date_lastlogin,
									c.notification_status_changed,
									cg.name as group_name
								FROM ' . $this->tableName . ' c
									LEFT OUTER JOIN ' . TABLE_CUSTOMER_GROUPS . ' cg ON c.group_id = cg.id
								WHERE c.' . $this->primaryKey . ' = _RID_';
        $this->arrDetailsModeFields = array('separator_1' => array('separator_info' => array('legend' => _PERSONAL_DETAILS), 'first_name' => array('title' => _FIRST_NAME, 'type' => 'label'), 'last_name' => array('title' => _LAST_NAME, 'type' => 'label'), 'birth_date' => array('title' => _BIRTH_DATE, 'type' => 'date', 'format' => 'date', 'format_parameter' => $date_format_view), 'url' => array('title' => _URL, 'type' => 'label')), 'separator_2' => array('separator_info' => array('legend' => _BILLING_ADDRESS), 'company' => array('title' => _COMPANY, 'type' => 'label'), 'b_address' => array('title' => _ADDRESS, 'type' => 'label'), 'b_address_2' => array('title' => _ADDRESS_2, 'type' => 'label'), 'b_city' => array('title' => _CITY, 'type' => 'label'), 'b_zipcode' => array('title' => _ZIP_CODE, 'type' => 'label'), 'b_country' => array('title' => _COUNTRY, 'type' => 'enum', 'source' => $arr_countries), 'b_state' => array('title' => _STATE_PROVINCE, 'type' => 'label')), 'separator_3' => array('separator_info' => array('legend' => _CONTACT_INFORMATION), 'phone' => array('title' => _PHONE, 'type' => 'label'), 'fax' => array('title' => _FAX, 'type' => 'label'), 'email' => array('title' => _EMAIL_ADDRESS, 'type' => 'label')), 'separator_4' => array('separator_info' => array('legend' => _ACCOUNT_DETAILS), 'user_name' => array('title' => _USERNAME, 'type' => 'label'), 'group_name' => array('title' => _CUSTOMER_GROUP, 'type' => 'label'), 'preferred_language' => array('title' => _PREFERRED_LANGUAGE, 'type' => 'enum', 'source' => $arr_languages)), 'separator_5' => array('separator_info' => array('legend' => _OTHER), 'date_created' => array('title' => _DATE_CREATED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'date_lastlogin' => array('title' => _LAST_LOGIN, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'registered_from_ip' => array('title' => _REGISTERED_FROM_IP, 'type' => 'label'), 'last_logged_ip' => array('title' => _LAST_LOGGED_IP, 'type' => 'label'), 'email_notifications' => array('title' => _EMAIL_NOTIFICATION, 'type' => 'label'), 'notification_status_changed' => array('title' => _NOTIFICATION_STATUS_CHANGED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'customer_active' => array('title' => _ACTIVE, 'type' => 'label'), 'customer_removed' => array('title' => _REMOVED, 'type' => 'label'), 'comments' => array('title' => _COMMENTS, 'type' => 'label')), 'separator_6' => array('separator_info' => array('legend' => _LISTINGS), 'orders_count' => array('title' => _ORDERS_COUNT, 'type' => 'label'), 'plan1_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[1], 'type' => 'label'), 'plan2_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[2], 'type' => 'label'), 'plan3_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[3], 'type' => 'label'), 'plan4_listings' => array('title' => _ADVERTISE_PLAN . ' ' . $arr_plans[4], 'type' => 'label')));
    }
Example #5
0
 function suspend($suspend_type = 1)
 {
     $data['cart'] = $this->sale_lib->get_cart();
     $data['subtotal'] = $this->sale_lib->get_subtotal();
     $data['taxes'] = $this->sale_lib->get_taxes();
     $data['total'] = $this->sale_lib->get_total();
     $data['receipt_title'] = lang('sales_receipt');
     $data['transaction_time'] = date(get_date_format() . ' ' . get_time_format());
     $customer_id = $this->sale_lib->get_customer();
     $employee_id = $this->Employee->get_logged_in_employee_info()->person_id;
     $sold_by_employee_id = $this->sale_lib->get_sold_by_employee_id();
     $comment = $this->sale_lib->get_comment();
     $comment = $this->sale_lib->get_comment();
     $show_comment_on_receipt = $this->sale_lib->get_comment_on_receipt();
     $emp_info = $this->Employee->get_info($employee_id);
     //Alain Multiple payments
     $data['payments'] = $this->sale_lib->get_payments();
     $data['amount_change'] = $this->sale_lib->get_amount_due() * -1;
     $data['balance'] = $this->sale_lib->get_payment_amount(lang('sales_store_account'));
     $data['employee'] = $emp_info->first_name . ' ' . $emp_info->last_name;
     if ($customer_id != -1) {
         $cust_info = $this->Customer->get_info($customer_id);
         $data['customer'] = $cust_info->first_name . ' ' . $cust_info->last_name . ($cust_info->company_name == '' ? '' : ' - ' . $cust_info->company_name) . ($cust_info->account_number == '' ? '' : ' - ' . $cust_info->account_number);
     }
     $total_payments = 0;
     foreach ($data['payments'] as $payment) {
         $total_payments += $payment['payment_amount'];
     }
     $sale_id = $this->sale_lib->get_suspended_sale_id();
     //SAVE sale to database
     $sale_id = $this->Sale->save($data['cart'], $customer_id, $employee_id, $sold_by_employee_id, $comment, $show_comment_on_receipt, $data['payments'], $sale_id, $suspend_type, '', '', $this->config->item('change_sale_date_when_suspending') ? date('Y-m-d H:i:s') : FALSE, $data['balance']);
     $data['sale_id'] = $this->config->item('sale_prefix') . ' ' . $sale_id;
     if ($data['sale_id'] == $this->config->item('sale_prefix') . ' -1') {
         $data['error_message'] = lang('sales_transaction_failed');
     }
     $this->sale_lib->clear_all();
     if ($this->config->item('show_receipt_after_suspending_sale')) {
         redirect('sales/receipt/' . $sale_id);
     } else {
         $this->_reload(array('success' => lang('sales_successfully_suspended_sale')));
     }
 }
Example #6
0
		<div id="user-nav" class="hidden-print hidden-xs">
			<ul class="btn-group ">
				<li class="btn  hidden-xs"><a title="" href="<?php 
echo site_url('login/switch_user');
?>
" data-toggle="modal" data-target="#myModal" ><i class="icon fa fa-user fa-2x"></i> <span class="text">	<?php 
echo lang('common_welcome') . " <b> {$user_info->first_name} {$user_info->last_name}! </b>";
?>
</span></a></li>
				<li class="btn  hidden-xs disabled" >
					<a title="" href="" onclick="return false;"><i class="icon fa fa-clock-o fa-2x"></i> <span class="text">
					<?php 
echo date(get_time_format());
?>
					<?php 
echo date(get_date_format());
?>
					</span></a>
				</li>
				<?php 
if ($this->Employee->has_module_permission('config', $this->Employee->get_logged_in_employee_info()->person_id)) {
    ?>
					<li class="btn "><?php 
    echo anchor("config", '<i class="icon fa fa-cog"></i><span class="text">' . lang("common_settings") . '</span>');
    ?>
</li>
				<?php 
}
?>
        <li class="btn  ">
					<?php 
/**
 *  Format date
 *  	@param $date
 *  	@param $format
 *  	@param $empty_text
 *  	@param $locale 
 */
function format_date($date, $format = '', $empty_text = '', $locale = false)
{
    $format = $format == '' ? get_date_format() : $format;
    if ($date != '' && $date != '0000-00-00') {
        $date_new = mktime(0, 0, 0, substr($date, 5, 2), substr($date, 8, 2), substr($date, 0, 4));
        // convert date according to local settings
        if ($locale && Application::Get('lang') != 'en') {
            $format = str_replace('%b', get_month_local(@strftime('%m', $date_new)), get_date_format('', false, true));
            return @strftime($format, $date_new);
        }
        return @date($format, $date_new);
    } else {
        return $empty_text;
    }
}
Example #8
0
            case 7:
                $postername = $db->select_single_value("xebura_VENUE", "AF_VENUE_NAME", " WHERE AF_VENUE_ID='" . $news_rows['AF_NEWS_POSTER_ID'] . "'");
                break;
            case 8:
                $postername = $db->select_single_value("xebura_BUYER", "AF_BUYER_COMPANYNAME", " WHERE AF_BUYER_ID='" . $news_rows['AF_NEWS_POSTER_ID'] . "'");
                break;
            default:
                $postername = "Unknown";
                break;
        }
        $temp['title'] = ucwords(html_script_escape($news_rows['AF_NEWS_TITLE']));
        $temp['news'] = truncate(ucfirst(html_script_escape(nl2br($news_rows['AF_NEWS_DESC']))), 50);
        $temp['poster'] = member_type($poster_aid);
        $temp['postername'] = ucwords(html_script_escape($postername));
        $postername = '';
        $temp['date'] = get_date_format($news_rows['AF_NEWS_DATE']);
        $temp['time'] = get_time_format($news_rows['AF_NEWS_TIME']);
        $posted_to_mid = $news_rows['AF_NEWS_POSTEDTO_MID'];
        $temp['posted_to_cid'] = encode($posted_to_mid);
        $posted_to_mid = '';
        if ($i == 0) {
            $news_last_update = $temp['date'];
        }
        $my_con_news[$i++] = $temp;
    }
}
$smarty->assign("NEWS_LASTUPDATED", $news_last_update);
$smarty->assign("NUM_CON_NEWS", $NUM_CON_NEWS);
$smarty->assign("my_con_news", $my_con_news);
$smarty->assign("has_con_news", $has_con_news);
/* End of force feed details. */
Example #9
0
 function graphical_summary_pawns($start_date, $end_date, $sale_type)
 {
     $this->check_action_permission('view_pawns');
     $start_date = rawurldecode($start_date);
     $end_date = date('Y-m-d 23:59:59', strtotime(rawurldecode($end_date)));
     $this->load->model('reports/Summary_pawns');
     $model = $this->Summary_pawns;
     $model->setParams(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type));
     $this->Pawn->create_pawns_temp_table(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type));
     $data = array("title" => lang('reports_pawns_summary_report'), "graph_file" => site_url("reports/graphical_summary_pawns_graph/{$start_date}/{$end_date}/{$sale_type}"), "subtitle" => date(get_date_format(), strtotime($start_date)) . '-' . date(get_date_format(), strtotime($end_date)), "summary_data" => $model->getSummaryData());
     $this->load->view("reports/graphical", $data);
 }
Example #10
0
echo form_label(lang('sales_receipt') . ':', 'sales_receipt', array('class' => 'col-sm-3 col-md-3 col-lg-2 control-label '));
?>
		<div class="col-sm-9 col-md-9 col-lg-10 sale-s">
			<?php 
echo anchor('sales/receipt/' . $sale_info['sale_id'], $this->config->item('sale_prefix') . ' ' . $sale_info['sale_id'], array('target' => '_blank'));
?>
		</div>
	</div>

	<div class="form-group">	
		<?php 
echo form_label(lang('sales_date') . ':', 'date', array('class' => 'col-sm-3 col-md-3 col-lg-2 control-label '));
?>
		<div class="col-sm-9 col-md-9 col-lg-10">
			<?php 
echo form_input(array('name' => 'date', 'value' => date(get_date_format(), strtotime($sale_info['sale_time'])), 'id' => 'date'));
?>
		</div>
	</div>

	<div class="form-group">	
		<?php 
echo form_label(lang('sales_customer') . ':', 'customer', array('class' => 'col-sm-3 col-md-3 col-lg-2 control-label '));
?>
		<div class="col-sm-9 col-md-3 col-lg-4 sale-s">
			<?php 
echo form_dropdown('customer_id', $customers, $sale_info['customer_id'], 'id="customer_id" class="form-control"');
?>
			&nbsp;
			<?php 
if ($sale_info['customer_id']) {
Example #11
0
/**
 * This function attempts to get a UNIX timestamp by testing
 * the date given through a number of known date types.
 * if the date is not in one of these types, it will simply
 * return false.
 * NOTE: This function may now return 64-bit timestamps, 
 * so its output should be passed to carl_date() or a similar 
 * 64-bit compatible function.
 * @param mixed $value the date string or integer to be converted into timestamp
 * @return $timestamp
 */
function get_unix_timestamp($value)
{
    // in php5 the string 0000-00-00 00:00:00 returns a timestamp - in php4 it does not ... accordingly we do this:
    if ($value === '0000-00-00 00:00:00') {
        return false;
    }
    $format = get_date_format($value);
    if ($format == 'mysql_datetime') {
        $value = datetime_to_unix($value, false);
    } elseif ($format == 'mysql_timestamp') {
        $value = timestamp_to_unix($value);
    } elseif ($format == 'exif_datetime') {
        $value = exif_datetime_to_unix($value);
    } elseif ($format == 'mysql_date') {
        $value = mysql_date_to_unix($value);
    } elseif ($format == 'unix_timestamp') {
        $value = $value;
    } else {
        if (!empty($format)) {
            trigger_error('get_date_format() returned unknown string: ' . $format);
        }
        $value = false;
    }
    // mktime can return funky results if it is given a bad date.
    // generally, -1 is returned for a bad date.
    if ($value == -1) {
        return false;
    } else {
        return $value;
    }
}
Example #12
0
 function receipt($receiving_id)
 {
     //Before changing the recv session data, we need to save our current state in case they were in the middle of a recv
     $this->receiving_lib->save_current_recv_state();
     $receiving_info = $this->Receiving->get_info($receiving_id)->row_array();
     $this->receiving_lib->copy_entire_receiving($receiving_id);
     $data['cart'] = $this->receiving_lib->get_cart();
     $data['total'] = $this->receiving_lib->get_total();
     $data['receipt_title'] = lang('receivings_receipt');
     $data['transaction_time'] = date(get_date_format() . ' ' . get_time_format(), strtotime($receiving_info['receiving_time']));
     $supplier_id = $this->receiving_lib->get_supplier();
     $emp_info = $this->Employee->get_info($receiving_info['employee_id']);
     $data['payment_type'] = $receiving_info['payment_type'];
     $data['employee'] = $emp_info->first_name . ' ' . $emp_info->last_name;
     if ($supplier_id != -1) {
         $supplier_info = $this->Supplier->get_info($supplier_id);
         $data['supplier'] = $supplier_info->company_name;
         if ($supplier_info->first_name || $supplier_info->last_name) {
             $data['supplier'] .= ' (' . $supplier_info->first_name . ' ' . $supplier_info->last_name . ')';
         }
     }
     $data['receiving_id'] = 'RECV ' . $receiving_id;
     $current_location_id = $this->Employee->get_logged_in_employee_current_location_id();
     $current_location = $this->Location->get_info($receiving_info['location_id']);
     $data['transfer_from_location'] = $current_location->name;
     if ($receiving_info['transfer_to_location_id'] > 0) {
         $transfer_to_location = $this->Location->get_info($receiving_info['transfer_to_location_id']);
         $data['transfer_to_location'] = $transfer_to_location->name;
     }
     $this->load->view("receivings/receipt", $data);
     $this->receiving_lib->clear_all();
     //Restore previous state saved above
     $this->receiving_lib->restore_current_recv_state();
 }
    ?>
</th>
								</tr>
							</thead>
							<tbody>
								<?php 
    $amount_due = false;
    foreach ($data['store_account_transactions'] as $transaction) {
        ?>
								<tr>
									<td><?php 
        echo $transaction['sno'];
        ?>
</td>
									<td><?php 
        echo date(get_date_format() . ' ' . get_time_format(), strtotime($transaction[$date_column]));
        ?>
</td>
									<td><?php 
        echo $transaction['sale_id'] ? anchor('sales/receipt/' . $transaction['sale_id'], $this->config->item('sale_prefix') . ' ' . $transaction['sale_id'], array('target' => '_blank')) : '-';
        ?>
</td>
									<td><?php 
        echo $transaction['transaction_amount'] > 0 ? to_currency($transaction['transaction_amount']) : to_currency(0);
        ?>
</td>
									<td><?php 
        echo $transaction['transaction_amount'] < 0 ? to_currency($transaction['transaction_amount'] * -1) : to_currency(0);
        ?>
</td>
									<td><?php 
Example #14
0
echo form_label(lang('receivings_receipt') . ':', 'receipt', array('class' => 'col-sm-3 col-md-3 col-lg-2 control-label'));
?>
						<div class="col-sm-9 col-md-9 col-lg-10 sale-s">
							<?php 
echo anchor('receivings/receipt/' . $receiving_info['receiving_id'], 'RECV ' . $receiving_info['receiving_id'], array('target' => '_blank'));
?>
						</div>
					</div>
	
					<div class="form-group">
					<?php 
echo form_label(lang('sales_date') . ':', 'date', array('class' => 'col-sm-3 col-md-3 col-lg-2 control-label'));
?>
						<div class="col-sm-9 col-md-9 col-lg-10 sale-s">
							<?php 
echo form_input(array('name' => 'date', 'value' => date(get_date_format(), strtotime($receiving_info['receiving_time'])), 'id' => 'date'));
?>
						</div>
					</div>
	
					<div class="form-group">
					<?php 
echo form_label(lang('receivings_supplier') . ':', 'supplier', array('class' => 'col-sm-3 col-md-3 col-lg-2 control-label'));
?>
						<div class="col-sm-9 col-md-9 col-lg-10 sale-s">
							<?php 
echo form_dropdown('supplier_id', $suppliers, $receiving_info['supplier_id'], 'id="supplier_id"');
?>
						</div>
					</div>
	
 /**
  * устанавливает переменные для скрипта datepicker'а
  *
  * @param array $content массив с переменными
  * @return ничего не возвращает
  */
 function datepicker_vars(&$content)
 {
     $week_start = period_first_day_of_the_week() - 1;
     // period_first_day_of_the_week() возвращает:
     // 1 - воскресенье, 2 - понедельник, 7 - суббота,
     // а нужно для datepicker - 1 - понедельник, 7 - воскресенье.
     // т.е. если $week_start == 0, то это воскресенье
     if (!$week_start) {
         $week_start = 7;
     }
     // OLD WAY
     /*
     $date_format = get_format('date_input');
     
     $date_format = str_replace('%m', 'mm', $date_format);   	
     $date_format = str_replace('%d', 'dd', $date_format);    
     $date_format = str_replace('%Y', 'yy', $date_format);
     
     
     $content['DPDATEFORMAT'] = "'$date_format'";
     */
     $date_format = get_date_format();
     $date_format = str_replace('m', 'mm', $date_format);
     $date_format = str_replace('d', 'dd', $date_format);
     $date_format = str_ireplace('y', 'yy', $date_format);
     /**
      * текущий датапикер форматирует год только как yyyy
      * или я не знаю как он это делает.
      * поэтому год в датах только в полном формате
      * @author Semerenko
      */
     //$date_format = str_replace('Y', 'yyyy', $date_format);
     // Zend date format
     //$date_format = Zend_Locale_Format::getDateFormat(get_instance()->locale);
     // simple way
     //$date_format = 'mm.dd.yy';
     $content['DPDATEFORMAT'] = '"' . $date_format . '"';
     $content['DPWEEKSTART'] = $week_start;
 }
Example #16
0
        echo '<label id="comment_label" for="change_sale_date_enable" class="checkbox">';
        echo lang('sales_change_date');
        echo form_checkbox(array('name' => 'change_sale_date_enable', 'id' => 'change_sale_date_enable', 'value' => '1', 'checked' => (bool) $change_sale_date_enable));
        echo ':</label>  ';
        ?>
				<div class="field_row clearfix" id="change_sale_input">
					<div class='form_field'>
					
					<div id="change_sale_date_picker" class="input-group date datepicker" data-date="date(get_date_format())" data-date-format=<?php 
        echo json_encode(get_js_date_format());
        ?>
>
						<span class="input-group-addon"><i class="fa fa-calendar"></i></span>

					<?php 
        echo form_input(array('name' => 'change_sale_date', 'id' => 'change_sale_date', 'size' => '8', 'value' => date(get_date_format())));
        ?>
       
					</div>
					</div>
				</div>
				<?php 
    }
}
?>
			</li>
		</ul>

		</div>
</div>
<div id="keyboardhelp" style="display: none;" title="<?php 
Example #17
0
}
?>

<?php 
echo lang('sales_total');
?>
: <?php 
echo $this->config->item('round_cash_on_sales') && $is_sale_cash_payment ? str_replace('&#8209;', '-', to_currency(round_to_nearest_05($total))) : str_replace('&#8209;', '-', to_currency($total));
?>

<?php 
foreach ($payments as $payment_id => $payment) {
    ?>

<?php 
    echo isset($show_payment_times) && $show_payment_times ? date(get_date_format() . ' ' . get_time_format(), strtotime($payment['payment_date'])) : lang('sales_payment');
    ?>
  <?php 
    if ($is_integrated_credit_sale || sale_has_partial_credit_card_payment()) {
        $splitpayment = explode(':', $payment['payment_type']);
        echo $splitpayment[0];
        ?>
: <?php 
        echo $payment['card_issuer'] . ' ' . $payment['truncated_card'];
        ?>
 <?php 
    } else {
        $splitpayment = explode(':', $payment['payment_type']);
        echo $splitpayment[0];
        ?>
 <?php 
Example #18
0
								<div class="form-group offset1">
								<?php 
        echo form_label(lang('items_promo_end_date') . ':', '', array('class' => 'col-sm-3 col-md-3 col-lg-2 control-label text-info wide'));
        ?>
							    <div class="col-sm-9 col-md-9 col-lg-10">
							    	<div class="input-group date datepicker" data-date="<?php 
        echo $location_items[$location->location_id]->item_id !== '' && $location_items[$location->location_id]->end_date ? date(get_date_format(), strtotime($location_items[$location->location_id]->end_date)) : '';
        ?>
" data-date-format=<?php 
        echo json_encode(get_js_date_format());
        ?>
>
		  								<span class="input-group-addon"><i class="fa fa-calendar"></i></span>

										    <?php 
        echo form_input(array('name' => 'locations[' . $location->location_id . '][end_date]', 'size' => '8', 'class' => 'form-control form-inps', 'value' => $location_items[$location->location_id]->item_id !== '' && $location_items[$location->location_id]->end_date ? date(get_date_format(), strtotime($location_items[$location->location_id]->end_date)) : ''));
        ?>
 
								    </div>
								</div>
							</div>
						</div>
						<div class="form-group override-taxes-container">
							<?php 
        echo form_label(lang('items_override_default_tax') . ':', '', array('class' => 'col-sm-3 col-md-3 col-lg-2 control-label wide'));
        ?>

							<div class="col-sm-9 col-md-9 col-lg-10">
								<?php 
        echo form_checkbox(array('name' => 'locations[' . $location->location_id . '][override_default_tax]', 'class' => 'override_default_tax_checkbox  delete-checkbox', 'value' => 1, 'checked' => $location_items[$location->location_id]->item_id !== '' ? (bool) $location_items[$location->location_id]->override_default_tax : FALSE));
        ?>
function get_current($period) {
  return date(get_date_format($period));
}
Example #20
0
echo lang("employees_employee");
?>
</td><td width="15%"><?php 
echo lang("items_in_out_qty");
?>
</td><td width="45%"><?php 
echo lang("items_remarks");
?>
</td></tr></thead>
								<tbody>
									<?php 
foreach ($this->Inventory->get_inventory_data_for_item($item_info->item_id)->result_array() as $row) {
    ?>
										<tr  align="center">
											<td><?php 
    echo date(get_date_format() . ' ' . get_time_format(), strtotime($row['trans_date']));
    ?>
</td>
											<td>
												<?php 
    $person_id = $row['trans_user'];
    $employee = $this->Employee->get_info($person_id);
    echo $employee->first_name . " " . $employee->last_name;
    ?>
											</td>
											<td align="right"><?php 
    echo to_quantity($row['trans_inventory']);
    ?>
</td>
											
											<?php 
Example #21
0
    function __construct($customer_id = '')
    {
        global $objLogin;
        $this->SetRunningTime();
        $this->params = array();
        if (isset($_POST['status'])) {
            $this->params['status'] = prepare_input($_POST['status']);
        }
        if (isset($_POST['status_changed'])) {
            $this->params['status_changed'] = prepare_input($_POST['status_changed']);
        }
        if (isset($_POST['additional_info'])) {
            $this->params['additional_info'] = prepare_input($_POST['additional_info']);
        }
        $this->currencyFormat = get_currency_format();
        $this->params['language_id'] = MicroGrid::GetParameter('language_id');
        $rid = MicroGrid::GetParameter('rid');
        $this->primaryKey = 'id';
        $this->tableName = TABLE_ORDERS;
        $this->dataSet = array();
        $this->error = '';
        $this->order_number = '';
        $this->order_status = '';
        $this->order_customer_id = '';
        $this->order_listings = '';
        $this->order_advertise_plan_id = '';
        $arr_statuses = array('0' => _PREPARING, '1' => _PENDING, '2' => _PAID, '3' => _COMPLETED, '4' => _REFUNDED);
        $arr_statuses_edit = array('1' => _PENDING, '2' => _PAID, '3' => _COMPLETED, '4' => _REFUNDED);
        $arr_statuses_edit_cut = array('1' => _PENDING, '2' => _PAID, '3' => _COMPLETED);
        $arr_statuses_refund = array('4' => _REFUNDED);
        $arr_statuses_customer_edit = array('4' => '');
        if ($customer_id != '') {
            $this->customer_id = $customer_id;
            $this->page = 'customer=my_orders';
            $this->actions = array('add' => false, 'edit' => false, 'details' => false, 'delete' => false);
        } else {
            $this->customer_id = '';
            $this->page = 'admin=mod_payments_orders';
            $this->actions = array('add' => false, 'edit' => false, 'details' => false, 'delete' => $objLogin->IsLoggedInAs('owner') ? true : false);
        }
        $this->actionIcons = true;
        $this->allowRefresh = true;
        $this->formActionURL = 'index.php?' . $this->page;
        $this->allowLanguages = false;
        $this->languageId = '';
        // ($this->params['language_id'] != '') ? $this->params['language_id'] : Languages::GetDefaultLang();
        $this->WHERE_CLAUSE = 'WHERE 1=1';
        if ($customer_id != '') {
            $this->WHERE_CLAUSE = 'WHERE ' . $this->tableName . '.status != 0 AND ' . $this->tableName . '.customer_id = ' . (int) $customer_id;
        }
        $this->ORDER_CLAUSE = 'ORDER BY ' . $this->tableName . '.id DESC';
        // ORDER BY date_created DESC
        $this->isAlterColorsAllowed = true;
        $this->isPagingAllowed = true;
        $this->pageSize = 30;
        $this->isSortingAllowed = true;
        $datetime_format = get_datetime_format();
        $date_format = get_date_format();
        $date_format_settings = get_date_format('view', true);
        $this->currency_format = get_currency_format();
        $pre_currency_symbol = Application::Get('currency_symbol_place') == 'left' ? Application::Get('currency_symbol') : '';
        $post_currency_symbol = Application::Get('currency_symbol_place') == 'right' ? Application::Get('currency_symbol') : '';
        $this->collect_credit_card = ModulesSettings::Get('payments', 'online_collect_credit_card');
        $this->isFilteringAllowed = true;
        // define filtering fields
        $this->arrFilteringFields = array(_ORDER_NUMBER => array('table' => $this->tableName, 'field' => 'order_number', 'type' => 'text', 'sign' => 'like%', 'width' => '70px'), _DATE => array('table' => $this->tableName, 'field' => 'payment_date', 'type' => 'calendar', 'date_format' => $date_format_settings, 'sign' => 'like%', 'width' => '80px', 'visible' => true));
        if ($this->customer_id == '') {
            $this->arrFilteringFields[_CUSTOMER] = array('table' => TABLE_CUSTOMERS, 'field' => 'user_name', 'type' => 'text', 'sign' => 'like%', 'width' => '70px');
        }
        $this->arrFilteringFields[_STATUS] = array('table' => $this->tableName, 'field' => 'status', 'type' => 'dropdownlist', 'source' => $arr_statuses_edit, 'sign' => '=', 'width' => '');
        //----------------------------------------------------------------------
        // VIEW MODE
        //----------------------------------------------------------------------
        $this->VIEW_MODE_SQL = 'SELECT
								' . $this->tableName . '.' . $this->primaryKey . ',
								' . $this->tableName . '.order_number,
								' . $this->tableName . '.order_description,
								' . $this->tableName . '.order_price,
								' . $this->tableName . '.total_price,
								CONCAT(' . TABLE_CURRENCIES . '.symbol, "", ' . $this->tableName . '.total_price) as mod_total_price,
								' . $this->tableName . '.currency,
								' . $this->tableName . '.advertise_plan_id,
								' . $this->tableName . '.listings_amount,
								' . $this->tableName . '.customer_id,
								' . $this->tableName . '.transaction_number,
								' . $this->tableName . '.created_date,
								' . $this->tableName . '.payment_date,
								' . $this->tableName . '.payment_type,
								' . $this->tableName . '.payment_method,
								' . $this->tableName . '.status,
								' . $this->tableName . '.status_changed,
								CASE
									WHEN ' . $this->tableName . '.payment_type = 0 THEN "' . _ONLINE_ORDER . '"
									WHEN ' . $this->tableName . '.payment_type = 1 THEN "' . _PAYPAL . '"
									WHEN ' . $this->tableName . '.payment_type = 2 THEN "2CO"
									WHEN ' . $this->tableName . '.payment_type = 3 THEN "Authorize.Net"
									ELSE "' . _UNKNOWN . '"
								END as m_payment_type,
								CASE
									WHEN ' . $this->tableName . '.payment_method = 0 THEN "' . _PAYMENT_COMPANY_ACCOUNT . '"
									WHEN ' . $this->tableName . '.payment_method = 1 THEN "' . _CREDIT_CARD . '"
									WHEN ' . $this->tableName . '.payment_method = 2 THEN "E-Check"
									ELSE "' . _UNKNOWN . '"
								END as m_payment_method,
								CASE
									WHEN ' . $this->tableName . '.status = 0 THEN "<span style=color:#960000>' . _PREPARING . '</span>"
									WHEN ' . $this->tableName . '.status = 1 THEN "<span style=color:#FF9966>' . _PENDING . '</span>"
									WHEN ' . $this->tableName . '.status = 2 THEN "<span style=color:#336699>' . _PAID . '</span>"
									WHEN ' . $this->tableName . '.status = 3 THEN "<span style=color:#009600>' . _COMPLETED . '</span>"
									WHEN ' . $this->tableName . '.status = 4 THEN "<span style=color:#969600>' . _REFUNDED . '</span>"
									ELSE "' . _UNKNOWN . '"
								END as m_status,
								' . TABLE_CUSTOMERS . '.user_name as customer_name,
								' . TABLE_CURRENCIES . '.symbol,
								CONCAT("<a href=\\"javascript:void(\'description\')\\" onclick=\\"javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'description\', \'", ' . $this->tableName . '.' . $this->primaryKey . ', "\')\\">[ ", "' . _DESCRIPTION . '", " ]</a>") as link_order_description,								
								IF(' . $this->tableName . '.status >= 2, CONCAT("<a href=\\"javascript:void(\'invoice\')\\" onclick=\\"javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'invoice\', \'", ' . $this->tableName . '.' . $this->primaryKey . ', "\')\\">[ ", "' . _INVOICE . '", " ]</a>"), "<span class=lightgray>' . _INVOICE . '</span>") as link_order_invoice,
								IF(' . $this->tableName . '.status = 0 OR ' . $this->tableName . '.status = 1, CONCAT("<a href=\\"javascript:void(0);\\" title=\\"Delete\\" onclick=\\"javascript:__mgDoPostBack(\'' . TABLE_ORDERS . '\', \'delete\', \'", ' . $this->tableName . '.' . $this->primaryKey . ', "\');\\">[ ' . _DELETE_WORD . ' ]</a>"), "<span class=lightgray>' . _DELETE_WORD . '</span>") as link_order_delete,
								IF(' . $this->tableName . '.status != 0, CONCAT("<a href=\\"javascript:void(0);\\" title=\\"' . _EDIT_WORD . '\\" onclick=\\"javascript:__mgDoPostBack(\'' . TABLE_ORDERS . '\', \'edit\', \'", ' . $this->tableName . '.' . $this->primaryKey . ', "\');\\">[ ' . _EDIT_WORD . ' ]</a>"), "<span class=lightgray>' . _EDIT_WORD . '</span>") as link_admin_order_edit,
								' . TABLE_ADVERTISE_PLANS_DESCRIPTION . '.name as plan_name,
								' . TABLE_CUSTOMERS . '.b_country
							FROM ' . $this->tableName . '
								LEFT OUTER JOIN ' . TABLE_CURRENCIES . ' ON ' . $this->tableName . '.currency = ' . TABLE_CURRENCIES . '.code
								LEFT OUTER JOIN ' . TABLE_CUSTOMERS . ' ON ' . $this->tableName . '.customer_id = ' . TABLE_CUSTOMERS . '.id
								LEFT OUTER JOIN ' . TABLE_ADVERTISE_PLANS_DESCRIPTION . ' ON (' . $this->tableName . '.advertise_plan_id = ' . TABLE_ADVERTISE_PLANS_DESCRIPTION . '.advertise_plan_id AND language_id = "' . Application::Get('lang') . '")
							';
        // define view mode fields
        if ($this->customer_id != '') {
            $this->arrViewModeFields = array('order_number' => array('title' => _ORDER_NUMBER, 'type' => 'label', 'align' => 'left', 'width' => '', 'header' => '', 'maxlength' => ''), 'created_date' => array('title' => _DATE, 'type' => 'label', 'align' => 'left', 'width' => '', 'header' => '', 'maxlength' => '', 'format' => 'date', 'format_parameter' => $datetime_format), 'plan_name' => array('title' => _PLAN, 'header_tooltip' => _ADVERTISE_PLAN, 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'listings_amount' => array('title' => _LISTINGS, 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'mod_total_price' => array('title' => _TOTAL_PRICE, 'type' => 'label', 'align' => 'right', 'width' => '', 'header' => '', 'maxlength' => '', 'sort_by' => 'total_price', 'sort_type' => 'numeric', 'format' => 'currency', 'format_parameter' => $this->currency_format . '|2'), 'm_status' => array('title' => _STATUS, 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'link_order_description' => array('title' => '', 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'link_order_invoice' => array('title' => '', 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'link_order_delete' => array('title' => '', 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''));
        } else {
            $this->arrViewModeFields = array('order_number' => array('title' => _ORDER, 'type' => 'label', 'align' => 'left', 'width' => '', 'header' => '', 'maxlength' => ''), 'created_date' => array('title' => _DATE, 'type' => 'label', 'align' => 'left', 'width' => '', 'header' => '', 'maxlength' => '', 'format' => 'date', 'format_parameter' => $datetime_format), 'customer_name' => array('title' => _CUSTOMER, 'type' => 'label', 'align' => 'left', 'width' => '', 'header' => '', 'maxlength' => ''), 'b_country' => array('title' => _COUNTRY, 'type' => 'label', 'align' => 'center', 'width' => '', 'height' => '', 'maxlength' => ''), 'plan_name' => array('title' => _PLAN, 'header_tooltip' => _ADVERTISE_PLAN, 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'listings_amount' => array('title' => _LISTINGS, 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'm_payment_type' => array('title' => _METHOD, 'header_tooltip' => _PAYMENT_METHOD, 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'total_price' => array('title' => _TOTAL_PRICE, 'type' => 'label', 'align' => 'right', 'width' => '', 'header' => '', 'maxlength' => '', 'sort_by' => 'total_price', 'sort_type' => 'numeric', 'format' => 'currency', 'format_parameter' => $this->currency_format . '|2'), 'symbol' => array('title' => '', 'type' => 'label', 'align' => 'left', 'width' => '', 'header' => '', 'maxlength' => ''), 'm_status' => array('title' => _STATUS, 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'link_order_description' => array('title' => '', 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'link_order_invoice' => array('title' => '', 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''), 'link_admin_order_edit' => array('title' => '', 'type' => 'label', 'align' => 'center', 'width' => '', 'header' => '', 'maxlength' => ''));
        }
        //----------------------------------------------------------------------
        // ADD MODE
        //----------------------------------------------------------------------
        // define add mode fields
        $this->arrAddModeFields = array();
        //----------------------------------------------------------------------
        // EDIT MODE
        //----------------------------------------------------------------------
        $this->EDIT_MODE_SQL = 'SELECT
								' . $this->tableName . '.' . $this->primaryKey . ',
								' . $this->tableName . '.order_number,
								' . $this->tableName . '.order_number as order_number_view,
								' . $this->tableName . '.order_description,
								' . $this->tableName . '.order_price,
								' . $this->tableName . '.vat_fee,
								' . $this->tableName . '.total_price,
								' . $this->tableName . '.currency,
								' . $this->tableName . '.advertise_plan_id,
								' . $this->tableName . '.listings_amount,
								' . $this->tableName . '.customer_id,								
								' . $this->tableName . '.cc_type,
								' . $this->tableName . '.cc_holder_name,
								IF(
									LENGTH(AES_DECRYPT(' . $this->tableName . '.cc_number, "' . PASSWORDS_ENCRYPT_KEY . '")) = 4,
									CONCAT("...", AES_DECRYPT(' . $this->tableName . '.cc_number, "' . PASSWORDS_ENCRYPT_KEY . '"), " (' . _CLEANED . ')"),
									AES_DECRYPT(' . $this->tableName . '.cc_number, "' . PASSWORDS_ENCRYPT_KEY . '")
								) as m_cc_number,								
								' . $this->tableName . '.cc_cvv_code,
								' . $this->tableName . '.cc_expires_month,
								' . $this->tableName . '.cc_expires_year,
								IF(' . $this->tableName . '.cc_expires_month != "", CONCAT(' . $this->tableName . '.cc_expires_month, "/", ' . $this->tableName . '.cc_expires_year), "") as m_cc_expires_date,
								' . $this->tableName . '.transaction_number,
								' . $this->tableName . '.payment_date,
								' . $this->tableName . '.payment_type,
								' . $this->tableName . '.payment_method,
								' . $this->tableName . '.status,
								' . $this->tableName . '.status_changed,
								' . $this->tableName . '.additional_info
							FROM ' . $this->tableName . '
								LEFT OUTER JOIN ' . TABLE_CURRENCIES . ' ON ' . $this->tableName . '.currency = ' . TABLE_CURRENCIES . '.code
								LEFT OUTER JOIN ' . TABLE_CUSTOMERS . ' ON ' . $this->tableName . '.customer_id = ' . TABLE_CUSTOMERS . '.id
							';
        if ($this->customer_id != '') {
            $WHERE_CLAUSE = 'WHERE ' . $this->tableName . '.status = 3 AND
								   ' . $this->tableName . '.customer_id = ' . $this->customer_id . ' AND
			                       ' . $this->tableName . '.id = _RID_';
        } else {
            $WHERE_CLAUSE = 'WHERE ' . $this->tableName . '.id = _RID_';
        }
        $this->EDIT_MODE_SQL = $this->EDIT_MODE_SQL . $WHERE_CLAUSE;
        // prepare trigger
        $sql = 'SELECT
		            status,
					IF(TRIM(cc_number) = \'\' OR LENGTH(AES_DECRYPT(cc_number, \'' . PASSWORDS_ENCRYPT_KEY . '\')) <= 4, \'hide\', \'show\') as cc_number_trigger
				FROM ' . $this->tableName . ' WHERE id = ' . (int) $rid;
        $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY, FETCH_ASSOC);
        if ($result[1] > 0) {
            $cc_number_trigger = $result[0]['cc_number_trigger'];
            $status_trigger = $result[0]['status'];
        } else {
            $cc_number_trigger = 'hide';
            $status_trigger = '0';
        }
        // define edit mode fields
        if ($customer_id != '') {
            $this->arrEditModeFields = array('order_number_view' => array('title' => _ORDER_NUMBER, 'type' => 'label'), 'status_changed' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => date('Y-m-d H:i:s')), 'status' => array('title' => _STATUS, 'type' => 'enum', 'width' => '210px', 'required' => true, 'readonly' => false, 'source' => $arr_statuses_customer_edit), 'order_number' => array('title' => '', 'type' => 'hidden', 'required' => false, 'default' => ''), 'customer_id' => array('title' => '', 'type' => 'hidden', 'required' => false, 'default' => ''));
        } else {
            $status_readonly = $status_trigger == '6' ? true : false;
            if ($status_trigger >= '2' && $status_trigger <= '6') {
                $ind = $status_trigger;
                while ($ind--) {
                    unset($arr_statuses_edit[$ind]);
                }
                $status_source = $arr_statuses_edit;
            } else {
                $status_source = $arr_statuses_edit_cut;
            }
            $this->arrEditModeFields = array('order_number_view' => array('title' => _ORDER_NUMBER, 'type' => 'label'), 'status_changed' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => date('Y-m-d H:i:s')), 'status' => array('title' => _STATUS, 'type' => 'enum', 'width' => '210px', 'required' => true, 'readonly' => $status_readonly, 'source' => $status_source, 'javascript_event' => ''), 'order_number' => array('title' => '', 'type' => 'hidden', 'required' => false, 'default' => ''), 'customer_id' => array('title' => '', 'type' => 'hidden', 'required' => false, 'default' => ''), 'cc_type' => array('title' => _CREDIT_CARD_TYPE, 'type' => 'label'), 'cc_holder_name' => array('title' => _CREDIT_CARD_HOLDER_NAME, 'type' => 'label'), 'm_cc_number' => array('title' => _CREDIT_CARD_NUMBER, 'type' => 'label', 'post_html' => $cc_number_trigger == 'show' ? '&nbsp;[ <a href="javascript:void(0);" onclick="if(confirm(\'' . _PERFORM_OPERATION_COMMON_ALERT . '\')) __mgDoPostBack(\'' . $this->tableName . '\',\'clean_credit_card\',\'' . $rid . '\')">' . _REMOVE . '</a> ]' : ''), 'm_cc_expires_date' => array('title' => _EXPIRES, 'type' => 'label'), 'cc_cvv_code' => array('title' => _CVV_CODE, 'type' => 'label'), 'additional_info' => array('title' => _ADDITIONAL_INFO, 'type' => 'textarea', 'width' => '390px', 'header' => '90px', 'editor_type' => 'simple', 'readonly' => false, 'default' => '', 'required' => false, 'validation_type' => '', 'unique' => false));
        }
        //----------------------------------------------------------------------
        // DETAILS MODE
        //----------------------------------------------------------------------
        $this->DETAILS_MODE_SQL = $this->VIEW_MODE_SQL . $WHERE_CLAUSE;
        $this->arrDetailsModeFields = array('order_number' => array('title' => _ORDER, 'type' => 'label'), 'order_description' => array('title' => _DESCRIPTION, 'type' => 'label'), 'order_price' => array('title' => _ORDER_PRICE, 'type' => 'label'), 'vat_fee' => array('title' => _VAT, 'type' => 'label'), 'total_price' => array('title' => _TOTAL_PRICE, 'type' => 'label'), 'currency' => array('title' => _CURRENCY, 'type' => 'label'), 'listings_amount' => array('title' => _LISTINGS, 'type' => 'label'), 'customer_name' => array('title' => _CUSTOMER, 'type' => 'label'), 'transaction_number' => array('title' => _TRANSACTION, 'type' => 'label'), 'payment_date' => array('title' => _DATE, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format), 'm_payment_type' => array('title' => _PAYED_BY, 'type' => 'label'), 'm_payment_method' => array('title' => _PAYMENT_METHOD, 'type' => 'label'), 'm_status' => array('title' => _STATUS, 'type' => 'label'), 'status_changed' => array('title' => _STATUS_CHANGED, 'type' => 'label', 'format' => 'date', 'format_parameter' => $datetime_format));
    }
Example #22
0
					<?php 
}
?>
				</tr>
				</thead>
				<tbody>
				<?php 
foreach ($suspended_sales as $suspended_sale) {
    ?>
					<tr>
						<td><?php 
    echo $suspended_sale['sale_id'];
    ?>
</td>
						<td><?php 
    echo date(get_date_format() . ' @ ' . get_time_format(), strtotime($suspended_sale['sale_time']));
    ?>
</td>
						<td><?php 
    echo $suspended_sale['suspended'] == 1 ? lang('sales_layaway') : lang('sales_estimate');
    ?>
</td>
						<td>
							<?php 
    if (isset($suspended_sale['customer_id'])) {
        $customer = $this->Customer->get_info($suspended_sale['customer_id']);
        $company_name = $customer->company_name;
        if ($company_name) {
            echo $customer->first_name . ' ' . $customer->last_name . ' (' . $customer->company_name . ')';
        } else {
            echo $customer->first_name . ' ' . $customer->last_name;
 /**
  * переводит значение заданного типа в строку
  *
  * @param mixed $data значение, которое нужно сконвертировать
  * @param string $type тип данных ('bool','date')
  * @param int $precision_default задание точного количества знаков после запятой
  * @return string полученная строка, представляющая данные
  */
 function type_to_str($data, $type, $precision_default = -1)
 {
     switch ($type) {
         case 'encode':
             return htmlentities($data, ENT_QUOTES, 'utf-8');
         case 'translate':
             return __($data);
         case "integer":
             /**
              * Локально пустые значения спокойно форматируется зендом в 0,
              * но на сервере, на orbitscipts.com? после форматирования пустого значение,
              * оно так и остаётся пустое. Я не знаю почему. 
              */
             if (is_null($data) || $data == '') {
                 $data = 0;
             }
             $res = Zend_Locale_Format::toInteger($data, array('locale' => get_instance()->locale));
             return $res;
         case "float":
             $precision = 2;
             /**
              * Определние нужной точности для денег
              */
             if ($precision_default < 0) {
                 $vals = explode('.', strval((double) $data));
                 if (isset($vals[1])) {
                     $len = strlen($vals[1]);
                     if ($len > 3) {
                         $precision = 4;
                     } elseif ($len > 2) {
                         $precision = 3;
                     }
                 }
             } else {
                 $precision = $precision_default;
             }
             return number_format($data, $precision, '.', '');
             //return Zend_Locale_Format::toFloat($data, array('locale'=> get_instance()->locale));
         //return Zend_Locale_Format::toFloat($data, array('locale'=> get_instance()->locale));
         case 'procent':
             return type_to_str($data, 'float', 2) . ' %';
         case "money":
             //return str_replace('%', type_to_str($data, 'float'), get_format('money'));
             if (is_null($data)) {
                 $data = 0;
             }
             /**
              * @todo Возможно прийдётся определять тип валюты как-то глобально, 
              *  когда понадобится использовать что-нибудь отличное от доллара. 
              */
             try {
                 $currency = new Zend_Currency(get_instance()->locale, 'USD');
             } catch (Zend_Currency_Exception $e) {
                 $currency = new Zend_Currency(get_instance()->default_locale, 'USD');
             }
             $precision = 2;
             /**
              * Определние нужной точности для денег
              */
             $vals = explode('.', strval((double) $data));
             if (isset($vals[1])) {
                 $len = strlen($vals[1]);
             }
             $currency->setFormat(array('precision' => $precision));
             try {
                 $value = trim($currency->toCurrency($data));
                 /**
                  * проверка preg_matchем нужна потмоу что, например в китайском валюта отображается
                  * как: US$0.00 
                  */
                 if (get_instance()->locale != 'en_US' && preg_match('|^[0-9,\\.\\$\\s\\xc2\\xa0]+$|', $value, $matches)) {
                     $value = '$' . trim(str_replace('$', '', $value));
                 }
             } catch (Exception $e) {
                 $value = '0.00';
             }
             return $value;
         case "nonzeromoney":
             if ($data == 0) {
                 return "—";
             }
             return type_to_str($data, "money");
         case "mysqldate":
             $data = mktime(0, 0, 0, substr($data, 5, 2), substr($data, 8, 2), substr($data, 0, 4));
             return date(get_date_format(), $data);
         case "mysqlfloat":
             //return str_replace(',','.',$data);
             return number_format($data, 8, '.', '');
         case 'databasedate':
             return date("Y-m-d", $data);
         case 'databasedatetime':
             return date("Y-m-d H:i:s", $data);
         case "date":
             if ($data == 0 || is_null($data)) {
                 return '';
             }
             return date(get_date_format(), $data);
         case "datetime":
             $res = date(get_date_format(), $data) . ' ' . date(get_time_format(), $data);
             return $res;
         case "bool":
             return $data ? "true" : "false";
         case 'textcode':
             $num = (int) ($data ^ 67894523);
             $text = '';
             while ($num) {
                 $text .= chr(ord('a') + $num % 26);
                 $num = (int) ($num / 26);
             }
             return $text;
         case "impressions":
             if ($data < 1000) {
                 return __('< 1 K');
             }
             if ($data < 5000) {
                 return __('1~5 K');
             }
             if ($data < 10000) {
                 return __('5~10 K');
             }
             if ($data < 50000) {
                 return __('10~50 K');
             }
             if ($data < 100000) {
                 return __('50~100 K');
             } else {
                 return __('> 100 K');
             }
         case "clicks":
             if ($data < 100) {
                 return __('< 100');
             }
             if ($data < 900) {
                 return '~ ' . round($data / 100) * 100;
             } else {
                 return '~ ' . round($data / 1000) . ' K';
             }
         case "mime":
             return '=?UTF-8?B?' . base64_encode($data) . '?=';
         default:
             return $data;
     }
 }
Example #24
0
echo lang('common_delete');
?>
</th>
				</tr>
				</thead>
				<tbody>
				<?php 
foreach ($suspended_receivings as $suspended_receiving) {
    ?>
					<tr>
						<td><?php 
    echo $suspended_receiving['receiving_id'];
    ?>
</td>
						<td><?php 
    echo date(get_date_format() . ' @ ' . get_time_format(), strtotime($suspended_receiving['receiving_time']));
    ?>
</td>
						<td>
							<?php 
    if (isset($suspended_receiving['supplier_id'])) {
        $supplier = $this->Supplier->get_info($suspended_receiving['supplier_id']);
        echo $supplier->company_name . ' (' . $supplier->first_name . ' ' . $supplier->last_name . ')';
    } else {
        ?>
								&nbsp;
							<?php 
    }
    ?>
						</td>
						<td><?php