コード例 #1
0
function getUserData($id = null, Mysql $mysql)
{
    $user = ['companyId' => 0, 'companyPrivs' => 0];
    if (!$id) {
        return $user;
    }
    $query = $mysql->mq('
								SELECT
									`companyId`,
									`companyPrivs`
								FROM
									`company`
								WHERE 
									`companyId` = ' . (int) $id . '
								LIMIT 1
									
						');
    return $mysql->assoc($query);
}
コード例 #2
0
ファイル: index.php プロジェクト: Zzepish/CMS-for-phone
header("Cache-Control: public, max-age=1");
require_once $_SERVER['DOCUMENT_ROOT'] . '/functions/system.php';
spl_autoload_register('autoloader');
error_reporting(-1);
$dbConnection = new Mysql();
$dataArray = [];
if (!isset($_GET['type'])) {
    exit;
}
if ($_GET['type'] === 'getAll') {
    $dataArray = ['categories' => [], 'subCategories' => [], 'metroes' => [], 'cities' => []];
    ////////////////////////Get all categories
    $query = $dbConnection->mq('
										SELECT 
											*
										FROM
											`categories`
									');
    if ($query->num_rows) {
        while ($result = $dbConnection->assoc($query)) {
            $dataArray['categories'][] = ['categoryId' => $result['catId'], 'imageUrl' => $result['catIconUrl'], 'catName' => $result['catName']];
        }
    }
    /////////////////////////Get all subCategories
    $query = $dbConnection->mq('
										SELECT 
											*
										FROM
											`subCategories`
									');
    if ($query->num_rows) {
コード例 #3
0
function eventsCabinetEdit($userId, Mysql $mysql, $cats = array(), $subCats = array())
{
    $getEvents = $mysql->mq('
									SELECT
										`companyId`,
										`eventId`, `eventName`, `eventCode`, `eventInfo`, `eventCondition`,
										`eventCatId`, `eventSubCatId`,
										`eventOldPrice`, `eventSale`, `eventSaleText`,
										`eventCatId`, `eventSubCatId`, `eventStartDate`, `eventEndDate`,
										`eventStopped` ,`spotId`, `spotName`,
										IF(`eventImage`="", "/img/addUserImage.jpg",`eventImage`) as `eventImage`,
										`eventOldPrice` - (`eventOldPrice` * (`eventSale`/100)) as `eventNewPrice`,
										IF(`eventEndDate` < NOW() OR `eventStopped` = 1 , "" , " active") as eventActivity,
										IF(`companyUpInCategory`>0,"active","") as upInCategory,
										IF(`companyUpInAllCategories`>0,"active","") as upInAllCategories,
										`companyUpInCategory`, `companyUpInAllCategories`,
										IF(`eventFreezeTime`>=NOW(),"active", "") as frozen
										
									FROM
										`event`
									LEFT JOIN
										`eventSpots`
									ON
										`eventId` = `eventSpotsEventId`
									LEFT JOIN
										`spots`
									ON
										`eventSpotsSpotId` = `spotId`
									LEFT JOIN
										`company`
									ON
										`companyId` = `eventCompanyId`
									WHERE
										`eventCompanyId` = ' . $userId . '
									ORDER BY
										`eventId` DESC
								');
    $ups = '';
    $eventId = null;
    $showEvents = [];
    $spotsList = [];
    $displayEvents = [];
    $spotsNames = [];
    $spotsToCheckbox = [];
    $spotsIds = [];
    $getSpotsList = $mysql->mq('
										SELECT
											`spotId`,`spotName`
										FROM
											`spots`
										WHERE
											`spotCompanyId` = ' . $userId . '
									');
    if ($getSpotsList->num_rows) {
        while ($result = $mysql->assoc($getSpotsList)) {
            $spotsList[$result['spotId']] = $result['spotName'];
        }
    }
    if ($getEvents->num_rows) {
        for ($i = 0; $result = $mysql->assoc($getEvents); $i++) {
            if (!$eventId || $eventId != $result['eventId']) {
                if (!is_null($eventId)) {
                    $showEvents[] = $result;
                    $eventId = $result['eventId'];
                } else {
                    $showEvents[] = $result;
                    $eventId = $result['eventId'];
                }
            }
            $spotsToCheckbox[$eventId][$result['spotId']] = $result['spotName'];
            $spotsNames[$eventId][] = $result['spotName'];
            $spotsIds[$eventId][] = $result['spotId'];
            if ($i == 0) {
                $ups = '<script>companyUpInCat=' . $result['companyUpInCategory'] . '; companyUpInAllCat=' . $result['companyUpInAllCategories'] . ';</script>';
            }
        }
    }
    ob_start();
    echo '<div>';
    for ($i = 0; $i < count($showEvents); $i++) {
        $class = '';
        $wrapper = '';
        $showEvents[$i]['spotsName'] = implode(', ', $spotsNames[$showEvents[$i]['eventId']]);
        $showEvents[$i]['spots'] = arrayToCheckbox($spotsList, $spotsIds[$showEvents[$i]['eventId']], ' class="checkboxLabel"', ' name="eventSpotsSpotId[]"');
        $showEvents[$i]['cats'] = arrayToSelect($cats, $showEvents[$i]['eventCatId'], '<option value="0">Категория</option>', 'name="eventCatId"');
        $showEvents[$i]['subCats'] = arrayToSelect($subCats[$showEvents[$i]['eventCatId']], $showEvents[$i]['eventSubCatId'], '<option value="0">Категория</option>', 'name="eventSubCatId"');
        if ($i % 2 != 0) {
            $class = 'second';
            $wrapper = '<div class="clear"></div></div><div>';
        }
        require $_SERVER['DOCUMENT_ROOT'] . '/pagesTemplates/eventsEdit.php';
        echo $wrapper;
    }
    echo '</div>';
    return ob_get_clean() . $ups;
}