function getCategories($u) { global $baseurl, $f; $path = ""; $d = new simple_html_dom(); $d->load(scraperwiki::scrape($u)); echo "Loaded URL: " . $u . "\n"; if ($d->find('div[id=ctl00_cphContent_gsaCatFacetContainer]')) { $breadcrumb = $d->find('div[id=breadcrumb]', 0); //foreach($breadcrumb as $b) { //echo "Breadcrumb = " . $b;} if (!is_null($breadcrumb)) { foreach ($breadcrumb->children() as $crumb) { $path .= trim($crumb->innertext) . "/"; } $path .= trim(strrchr($breadcrumb->innertext, ">"), "> "); } foreach ($d->find('div[id=ctl00_cphContent_gsaCatFacetContainer]', 0)->find('div[class=S2refinementsContainer]', 0)->children() as $div) { $name = trim(strstr($div->children(0)->innertext, "(", true)); $url = $baseurl . $div->children(0)->href; $data = array("Name" => $name, "Path" => $path, "URL" => $url); echo $path . "/" . $name . "\n"; if ($local) { fputcsv($f, array($name, $path, $url)); } else { scraperwiki::save_sqlite(array("URL"), $data); } getCategories($url); } } }
function categoryHandler() { $arr = getCategories(); for ($ctr = 0; $ctr < count($arr); $ctr++) { echo '<option>' . $arr[$ctr] . '</option>'; } }
function getCategories($parentId = null, &$items = array(), $showDisabled = true) { $groups = new \cf\ChildGroups($parentId, $showDisabled); foreach ($groups as $g) { $item = array('' => array('id' => $g->id(), 'code' => $g->code())); getCategories($g->id(), $item, $showDisabled); $items[$g->name()] = $item; } return $items; }
function createCategoryButtons() { $arrCat = getCategories(); $btn = "<div class='btn-group' role='group'>\n <button type='button' class='btn btn-default btnCat' id='All'>All</button>\n </div>"; $head = "<div class='btn-group' role='group'>"; $class = 'btn btn-default btnCat'; for ($ctr = 0; $ctr < count($arrCat); $ctr++) { $btn = $btn . $head . "<button type='button' class='" . $class . "' id='" . $arrCat[$ctr] . "'>" . $arrCat[$ctr] . "</button></div>"; } echo $btn; }
function getExpandedProfile(User $user, array $features, $include_empty = true) { //outline //display basic biographical information //get all MetaData categories applicable to this user. //get the value sets for each type //display substitute row in empty sets/hide category if specified var_dump($features); $types = getTypes_User($user); $categories = getCategories($types); $str = getBiographicalSketch($user, $features); //if categories are not included in $features, assume they are to be included return $str; }
public function returnAllMenuInfo($slug) { $results = \MenuItem::where('menu_item_slug', '=', $slug)->get(array('menu_item_description', 'menu_item_picture_uri', 'menu_item_name', 'menu_item_slug', 'menu_item_id', 'menu_item_category_fk', 'menu_item_short', 'menu_item_price')); foreach ($results as $result) { $menu_item_description = $result->menu_item_description; $menu_item_name = $result->menu_item_name; $menu_item_picture_uri = $result->menu_item_picture_uri; $menu_item_id = $result->menu_item_id; $slug = $result->menu_item_slug; $menu_item_category_fk = $result->menu_item_category_fk; $menu_item_short = $result->menu_item_short; $menu_item_price = $result->menu_item_price; } function getCategories() { $category = array(); $categories = \MenuCategory::get(); foreach ($categories as $cat) { $cat_name = $cat->menu_category_name; $cat_id = $cat->menu_category_id; $category[$cat_id] = $cat_name; } return $category; } function getDefault($menu_item_category_fk) { $results = \MenuCategory::where('menu_category_id', '=', $menu_item_category_fk)->get(array('menu_category_id')); foreach ($results as $result) { $category = $result->menu_category_id; } return $category; } $categories = getCategories(); $default = ""; if (isset($menu_item_category_fk)) { $default = getDefault($menu_item_category_fk); } if (\Auth::check()) { if (!isset($menu_item_description)) { return \Redirect::to('admin'); } return \View::make('menu-items.edit')->withMenuItemDescription($menu_item_description)->withMenuItemPictureUri($menu_item_picture_uri)->withMenuItemName($menu_item_name)->withMenuItemShort($menu_item_short)->withSlug($slug)->withCategories($categories)->withDefault($default)->withMenuItemPrice($menu_item_price); } return \Redirect::to('admin'); }
function getDepartmentWithCourses($collegeId) { //initialise array variables $data = []; $courses = []; $ids = []; //fetch departments $departments = getDepartments($collegeId); //append departments to data array //$data['departments'] = $departments; //get the ids of each department foreach ($departments as $key => $value) { //$ids[] = $value['id']; $data[$key]['department'] = $value; $data[$key]['courses'] = getCategories($value['id']); } return $data; }
function optimizeCategories($root) { $nodes = getCategories($root); if (sizeof($nodes) < MAX_LENGTH) { return; } $node = null; $destNode = null; for ($i = sizeof($nodes) - 1; $i >= MAX_LENGTH; $i--) { $node = $nodes[$i]; $destNode = getDestNode($root); moveNode($destNode, $node); } // Îáðàáîòàòü ïîäêàòåãîðèè $nodes = getCategories($root); for ($i = 0; $i < sizeof($nodes); $i++) { optimizeCategories($nodes[$i]); } }
function getBlogContentForCoverPage() { global $blogid, $blog, $service, $stats, $skinSetting; global $pd_category, $pd_categoryXhtml, $pd_archive, $pd_calendar, $pd_tags, $pd_notices, $pd_recentEntry; global $pd_recentComment, $pd_recentTrackback, $pd_link, $pd_authorList; $categories = getCategories($blogid); $totalPosts = getEntriesTotalCount($blogid); $pd_category = getCategoriesView($totalPosts, $categories, isset($category) ? $category : true); $pd_categoryXhtml = getCategoriesView($totalPosts, $categories, isset($category) ? $category : true, true); $pd_archive = getArchives($blogid); $pd_calendar = getCalendarView(getCalendar($blogid, true)); $pd_tags = getRandomTags($blogid); $pd_notices = getNotices($blogid); $pd_recentEntry = getRecentEntries($blogid); $pd_recentComment = getRecentComments($blogid); $pd_recentTrackback = getRecentTrackbacks($blogid); $pd_link = getLinks($blogid); $pd_authorList = User::getUserNamesOfBlog($blogid); }
function showVoteInput($q) { $info = explode(".", $q); $district = $info[0]; $machine = $info[1]; echo "<center><h1 class='title'>Enter Election Results for District: <span class='big'>{$district}</span>, Machine: <span class='big'>{$machine}</span></h1></center>"; echo "<form action = './saveInputs.php' method ='post'>"; //get categories $categoriesResult = getCategories(); $count = 0; $categoryCount = 0; echo "<table><tr><td class='category'>"; while ($category = mysql_fetch_array($categoriesResult)) { //get candidates $id = $category['category_id']; //echo " ID = {$id} "; $candidates = getCandidates($id); echo "<h1> {$category['category_name']}</h1><table>"; while ($candidate = mysql_fetch_array($candidates)) { $info = "{$district},{$machine},{$candidate['candidate_id']},"; //echo $info; $hidden = "candidateID" . $count++; echo "<tr><td width = 25px></td><td>{$candidate['candidate_name']}</td><td>"; echo "<input type ='number' id='{$candidate['candidate_id']}' name='{$candidate['candidate_id']}' value = "; echo "'"; echo getElectionResults($district, $machine, $candidate['candidate_id']); echo "'"; //$functionStr = "ajaxGetInfo({$info}, this.value)"; // . $info . ")"; echo " oninput='ajaxGetInfo(this.value, this.name)' min=0></td></tr>"; echo "<input type=hidden name = {$hidden} METHOD='POST' value='{$candidate['candidate_id']}'>"; // echo "<input type=hidden name = 'candidateID' METHOD='POST' value='{$candidate['candidate_id']}'>"; } echo "</table>"; echo "<input type=hidden id = 'district' value='{$district}'>"; echo "<input type=hidden id = 'machine' value='{$machine}'>"; if ($categoryCount % 3 == 2) { echo "</td><td style='padding-left:45px'>"; } $categoryCount++; } echo "</td></tr></table>"; }
function getCategories($parentId = null, &$items = array()) { $q = null; \cf\createStaticQuery($q, "\n\t\tSELECT id, name, url, tree_id, list_id\n\t\tFROM cf_admin_categories\n\t\tWHERE parent_id=:parent OR (parent_id IS NULL AND :parent IS NULL)\n\t\tORDER BY sort_order\n\t"); $q->setParam('parent', $parentId); $q->execute(); while ($q->fetch()) { $item = array('id' => $q->at('id'), 'name' => $q->at('name'), 'url' => $q->at('url') ? $q->at('url') . '&mid=' . $q->at('id') : (canRead($q->at('list_id')) ? 'list.php?vid=' . $q->at('list_id') . '&mid=' . $q->at('id') : ''), 'children' => array()); getCategories($q->at('id'), $item['children']); if ($q->at('tree_id') && canRead($q->at('tree_id'))) { getTree($q->at('tree_id'), null, $item['children'], $q->at('list_id') && canRead($q->at('list_id')) ? $q->at('list_id') : false, $q->at('id')); } if (count($item['children']) || $item['url']) { if (!$item['url']) { $item['url'] = 'category.php?id=' . $q->at('id') . '&mid=' . $q->at('id'); } $items[] = $item; } } $q->close(); return $items; }
function getChallenge() { $challenge = array(); if ($categories = getCategories()) { // Shuffle the categories. shuffle($categories); // retrieve the top four. $categories = array_slice($categories, 0, 4); // grab the images from the first. shuffle($categories[0]['images']); // use the first image. $challenge['image'] = $categories[0]['images'][0]; // Build the answer. $challenge['answer'] = array('id' => md5($challenge['image']['id'] . $categories[0]['id']), 'role' => $categories[0]['role'], 'title' => $categories[0]['title'], 'source' => $challenge['image']['source'], 'correct' => getResponse('correct'), 'incorrect' => getResponse('incorrect')); // Build the options. shuffle($categories); foreach ($categories as $category) { $challenge['options'][] = array('id' => $category['id'], 'title' => $category['title']['name'] . ($category['year'] ? ' (' . $category['year'] . ')' : '')); } } return (object) $challenge; }
public function showMenu() { function getMenuItem() { $items = \MenuItem::get(); foreach ($items as $item) { $item_price[] = $item->menu_item_price; $item_desc[] = $item->menu_item_short; $item_name[] = $item->menu_item_name; $item_fk[] = $item->menu_item_category_fk; } if (!isset($item)) { $items = null; return $items; } $items = array($item_name, $item_desc, $item_fk, $item_price); return $items; } function getCategories() { $categories = \MenuCategory::get(); foreach ($categories as $cat) { $cat_name[] = $cat->menu_category_name; $cat_id[] = $cat->menu_category_id; $category = array($cat_id, $cat_name); } return $category; } $items = getMenuItem(); if ($items === null) { return \Redirect::to('admin'); } $category = getCategories(); list($name, $desc, $fk, $price) = $items; list($cat_id, $cat) = $category; return \View::make('menu-items.menu')->withName($name)->withDesc($desc)->withFk($fk)->withPrice($price)->withCatId($cat_id)->withCatName($cat); }
function buildMenu(User $user) { $username = $user->getID(); $categories = getCategories(); $db = DBConnection::getConnection(); if (count($categories) == 0) { throw new Exception("There are no available categories for you"); } else { foreach ($categories as $catName) { $id = str_replace(" ", "", $catName) . "_btn"; echo "<p class='category' id='{$id}' onclick='showPanel(this)'>" . $catName . "</p>"; $query = "SELECT ID, NAME, ALERT FROM SCRIPTS WHERE CATEGORY = '{$catName}' AND ID IN (SELECT ID_SCRIPT FROM AUTHORIZATIONS WHERE ID_USER='******')"; try { $res = $db->query($query); $namePanel = str_replace(" ", "", $catName) . "_Panel"; if ($res->rowCount() <= 0) { echo "<ul class=\"scripts\" id=\"{$namePanel}\">"; echo "<p class='error'>No Available Scripts in this category</p>"; echo "</ul>"; } else { echo "<ul class=\"scripts\" id=\"{$namePanel}\">"; while ($info = $res->fetch(PDO::FETCH_ASSOC)) { $scriptName = $info["NAME"]; $scriptId = $info["ID"]; $scriptAlert = $info["ALERT"]; $row = "<li id=\"{$scriptId}\" about=\"{$scriptAlert}\" onclick=\"execCmd(this)\">{$scriptName}</li>"; echo $row; } echo "</ul>"; } } catch (Exception $e) { throw new Exception("Impossible to Execute Query that retrieve scripts for category " . $catName . ": " . $e->getMessage()); } } } }
removeItselfById('category-move-button'); trashSelect = document.createElement("SELECT"); trashSelect.id = "category"; trashSelect.name = "category"; trashSelect.onchange = function() { document.getElementById('trash-form').page.value=1; document.getElementById('trash-form').submit(); return false; }; trashOption = document.createElement("OPTION"); trashOption.innerHTML = "<?php echo _t('전체'); ?> "; trashOption.value = "0"; trashSelect.appendChild(trashOption); <?php foreach (getCategories($blogid) as $category) { ?> trashOption = document.createElement("OPTION"); trashOption.innerHTML = "<?php echo htmlspecialchars($category['name']); ?> "; trashOption.value = "<?php echo $category['id']; ?> "; <?php if ($category['id'] == $categoryId) { ?> trashOption.setAttribute("selected", "selected");
<?php } ?> </div> <div class="block"> <h3>Categories</h3> <!-- http://getbootstrap.com/components/#list-group --> <div class="list-group"> <a href="topics.php" class="list-group-item <?php echo is_active(null); ?> ">All Topics <span class="badge pull-right"></span></a> <?php foreach (getCategories() as $category) { ?> <a href="topics.php?category=<?php echo $category->id; ?> " class="list-group-item <?php echo is_active($category->id); ?> "><?php echo $category->name; ?> </a> <?php } ?>
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT) define('__TEXTCUBE_MOBILE__', true); require ROOT . '/library/preprocessor.php'; requireView('mobileView'); list($entries, $paging) = getEntryWithPaging($blogid, $suri['id']); $entry = $entries ? $entries[0] : null; printMobileHtmlHeader(htmlspecialchars($context->getProperty('blog.title'))); ?> <div id="pannels"> <!-- <h2><?php echo _t('카테고리'); ?> </h2> <?php echo getCategoriesView(getEntriesTotalCount($blogid), getCategories($blogid), true, true); ?> --> <h2><?php echo _text('최근에 달린 댓글'); ?> </h2> <?php $comments = getRecentComments($blogid); if (count($comments) > 0) { echo '<ul>'; } foreach ($comments as $comment) { ?> <li><a href="<?php echo $context->getProperty('uri.blog');
} // Update paths function updatePath($elem) { if ($elem["filename"] != 'imageurl') { $elem["file"] = "../../files/" . $elem["file"]; } return $elem; } /* BEGIN -- Get store data */ $domain = $_GET["store"]; $storeId = getStoreId($domain); // Logo $logoPath = getStoreLogo($domain); // Categories $categories = getCategories($storeId); // Products $searchTerm = $_GET["terms"]; $products = searchOnStore($storeId, $searchTerm, 30); $products = array_map("updatePath", $products); // Vat $vat_oux = getStoreById($storeId); $vat = $vat_oux[0]["vat"]; //loged in user $smarty->assign('userPermission', 'guest'); if (isset($_SESSION['storesLogin'][$storeId]['userId'])) { $userInfo = $_SESSION['storesLogin'][$storeId]['userId']; if (isset($userInfo)) { $userInfo = getAccount($userInfo); $userPermission = getAccountPermission($userInfo["id"]); $userPermission = $userPermission["name"];
<?php include_once './DbConnect.php'; function getCategories() { $db = new DbConnect(); // array for json response $response = array(); $response["categories"] = array(); // Mysql select query $result = mysql_query("SELECT * FROM t_detail_kelengkapan ORDER BY id_detail_kel DESC LIMIT 1"); while ($row = mysql_fetch_array($result)) { // temporary array to create single category $tmp = array(); $tmp["id"] = $row["id_detail_kel"]; $tmp["name"] = $row["id_user"]; // push category to final json array array_push($response["categories"], $tmp); } // keeping response header to json header('Content-Type: application/json'); // echoing json result echo json_encode($response); } getCategories();
function display_category_select($organisation_id = null, $group = null, $role = null, $proxy_id = null, $cat_id = null) { $types = MetaDataTypes::get($organisation_id, $group, $role, $proxy_id); $categories = getCategories($types); if (count($categories) == 0) { return "None"; } ob_start(); ?> <select id="associated_cat_id" name="associated_cat_id"> <?php foreach ($categories as $category) { echo build_option($category->getID(), $category->getLabel(), $cat_id == $category->getID()); } ?> </select> <?php return ob_get_clean(); }
?> : </td> <td align="left"><input name="description" type="text" maxlength="255" value="<?php echo $content['description']; ?> " class="inputBox" onchange="documentDirty=true;"></td></tr> <tr><td align="left"><?php echo $_lang['existing_category']; ?> : </td> <td align="left"> <select name="categoryid" onchange="documentDirty=true;"> <option> </option> <?php include_once MODX_MANAGER_PATH . 'includes/categories.inc.php'; foreach (getCategories() as $n => $v) { echo "\t\t\t" . '<option value="' . $v['id'] . '"' . ($content['category'] == $v['id'] ? ' selected="selected"' : '') . '>' . htmlspecialchars($v['category']) . "</option>\n"; } ?> </select></td></tr> <tr><td align="left" valign="top" style="padding-top:5px;"><?php echo $_lang['new_category']; ?> :</td> <td align="left" valign="top" style="padding-top:5px;"><input name="newcategory" type="text" maxlength="45" value="" class="inputBox" onchange="documentDirty=true;"></td></tr> <tr><td align="left"><?php echo $_lang['icon']; ?> <span class="comment">(32x32)</span>: </td> <td align="left"><input onchange="documentDirty=true;" type="text" maxlength="255" style="width: 235px;" name="icon" value="<?php echo $content['icon'];
function getExportContent() { $fake_suppliernumber = array('No Name', '000', '0000', 'Diverse', '', ' '); $ordernumber = 0; $missing_article = array(); $shop = 'hoh'; $catpaths = getCategoryPaths(); $shopArticleData_hoh = getShopArticleData($shop, $missing_article); $mentionArticleData = getMentionArticleData(); $count = 0; $content = 'Artikelnummer|Hersteller-Artikelnummer|EAN|Hersteller|Bezeichnung|Kategorie 1|HEK|Lagerbestand|Image|Deep-Link' . "\r\n"; $tmpContentArray = array(); $cats = array(); $catNbr = 0; $tmpCategories = array(); $categories = array(); foreach ($mentionArticleData as $key => $value) { unset($supplier, $suppliernumber, $ean, $art_bezeichnung, $net_price, $shop_ean, $shop_herst, $shop_herstnr, $shop_image, $shop_deeplink, $shop_categorie); $lagerbestand = 0; $shop_art_exists = 0; if ($value['VK_Netto'] > 0) { $net_price = $value['VK_Netto']; } else { if ($value['VK_Brutto'] > 0) { $net_price = $value['VK_Brutto'] / (1 + $value['mwst'] / 100); } else { if ($value['VK_Kalkulation'] > 0 && ($value['MLEKPREIS'] > 0 || $value['AEEKPREIS'] > 0)) { if ($value['Rieck-Bestand'] > 0) { $net_price = $value['MLEKPREIS'] * (1 + $value['VK_Kalkulation'] / 100); } else { $net_price = $value['AEEKPREIS'] * (1 + $value['VK_Kalkulation'] / 100); } } else { $net_price = 0; } } } if ($net_price > 0 && $net_price >= $value['MLEKPREIS'] && $net_price >= $value['AEEKPREIS']) { if (array_key_exists($key, $shopArticleData_hoh)) { $shop_art_exists = 1; $shop_ean = $shopArticleData_hoh[$key]['ean']; $art_bezeichnung = $shopArticleData_hoh[$key]['artikelbez']; $shop_herstnr = $shopArticleData_hoh[$key]['suppliernumber']; $shop_herst = $shopArticleData_hoh[$key]['supplier']; $shop_image = $shopArticleData_hoh[$key]['imageURL']; $shop_deeplink = $shopArticleData_hoh[$key]['URL']; } else { $missing_article[] = $key; } if ($shop_art_exists == 1) { if ($value['AREANCODE'] == 0 && $shop_ean != 0 || $value['AREANCODE'] == '' && $shop_ean != '') { $ean = $shop_ean; } else { $ean = $value['AREANCODE']; } if ($value['ARHERSTNR'] == '' && $shop_herstnr != '') { $suppliernumber = $shop_herstnr; } else { $suppliernumber = $value['ARHERSTNR']; } if (($value['KOHTEXT'] == '' || trim($value['KOHTEXT']) == "keine Angabe") && $shop_herst != '') { $supplier = $shop_herst; } else { $supplier = $value['KOHTEXT']; } if ($ean != 0 && $ean != '' || !in_array($suppliernumber, $fake_suppliernumber)) { if ($value['Rieck-Bestand'] > 0) { $lagerbestand = $value['Rieck-Bestand']; } else { $lagerbestand = $value['Conrad-Bestand']; } $net_price = number_format($net_price + 0, 2, ',', ''); $art_bezeichnung = str_replace('"', '""', $art_bezeichnung); $art_bezeichnung = str_replace('"', '""', $art_bezeichnung); $art_bezeichnung = str_replace('&', '&', $art_bezeichnung); $supplier = str_replace('&', '&', $supplier); if (key_exists($key, $catpaths) && key_exists($shop, $catpaths[$key])) { $categoriepath = $catpaths[$key][$shop]; } else { $categoriepath = ''; $cats[] = $shopArticleData_hoh[$key]['artikelNr']; $catNbr++; } if ($catNbr == 1000) { $tmpCatArray = getCategories($shop, $cats); if (!empty($tmpCategories)) { $tmpCategories = array_merge($tmpCategories, $tmpCatArray); } else { $tmpCategories = $tmpCatArray; } $catNbr = 0; unset($cats); } $tmpArray = array('ordernumber' => $key, 'suppliernumber' => $suppliernumber, 'ean' => $ean, 'supplier' => $supplier, 'artBez' => $art_bezeichnung, 'artikelNr' => $shopArticleData_hoh[$key]['artikelNr'], 'net_price' => $net_price, 'lagerbestand' => $lagerbestand, 'shop_image' => $shop_image, 'deeplink' => $shop_deeplink, 'shop' => $shop, 'category' => $categoriepath); $tmpContentArray[] = $tmpArray; } } } } if (!empty($cats)) { $tmpCatArray = getCategories($shop, $cats); if (!empty($tmpCategories)) { $tmpCategories = array_merge_recursive($tmpCategories, $tmpCatArray); } else { $tmpCategories = $tmpCatArray; } $catNbr = 0; unset($cats); } $categories[$shop] = $tmpCategories; foreach ($tmpContentArray as $contentValue) { if ($contentValue['category'] != '') { $shop_categorie = $contentValue['category']; } else { if (array_key_exists("'" . $contentValue['artikelNr'] . "'", $categories[$contentValue['shop']])) { $shop_categorie = $categories[$contentValue['shop']]["'" . $contentValue['artikelNr'] . "'"]; writeCategoryPaths($contentValue['ordernumber'], $contentValue['shop'], $shop_categorie); } else { $shop_categorie = $contentValue['shop']; } } $content .= $contentValue['ordernumber'] . '|' . $contentValue['suppliernumber'] . '|' . $contentValue['ean'] . '|' . $contentValue['supplier'] . '|"' . $contentValue['artBez'] . '"|' . $shop_categorie . '|' . $contentValue['net_price'] . '|' . $contentValue['lagerbestand'] . '|' . $contentValue['shop_image'] . '|' . $contentValue['deeplink'] . "\r\n"; } $result = writeCsvFile($content, 'w'); unset($content, $tmpCategories, $tmpContentArray); print '<br>AnzahlMissing: ' . count($missing_article); if (!empty($missing_article)) { $content = ''; $shop = 'getgoods'; unset($shopArticleData_hoh); $shopArticleData_hoh = getShopArticleData($shop, $missing_article); foreach ($mentionArticleData as $key => $value) { unset($supplier, $suppliernumber, $ean, $art_bezeichnung, $net_price, $shop_ean, $shop_herst, $shop_herstnr, $shop_image, $shop_deeplink, $shop_categorie); $lagerbestand = 0; $shop_art_exists = 0; if ($value['VK_Netto'] > 0) { $net_price = $value['VK_Netto']; } else { if ($value['VK_Brutto'] > 0) { $net_price = $value['VK_Brutto'] / (1 + $value['mwst'] / 100); } else { if ($value['VK_Kalkulation'] > 0 && ($value['MLEKPREIS'] > 0 || $value['AEEKPREIS'] > 0)) { if ($value['Rieck-Bestand'] > 0) { $net_price = $value['MLEKPREIS'] * (1 + $value['VK_Kalkulation'] / 100); } else { $net_price = $value['AEEKPREIS'] * (1 + $value['VK_Kalkulation'] / 100); } } else { $net_price = 0; } } } if ($net_price > 0 && $net_price >= $value['MLEKPREIS'] && $net_price >= $value['AEEKPREIS'] && in_array($key, $missing_article)) { if (array_key_exists($key, $shopArticleData_hoh)) { $shop_art_exists = 1; $shop_ean = $shopArticleData_hoh[$key]['ean']; $art_bezeichnung = $shopArticleData_hoh[$key]['artikelbez']; $shop_herstnr = $shopArticleData_hoh[$key]['suppliernumber']; $shop_herst = $shopArticleData_hoh[$key]['supplier']; $shop_image = $shopArticleData_hoh[$key]['imageURL']; $shop_deeplink = $shopArticleData_hoh[$key]['URL']; } else { $missing_article[] = $key; } if ($shop_art_exists == 1) { if ($value['AREANCODE'] == 0 && $shop_ean != 0 || $value['AREANCODE'] == '' && $shop_ean != '') { $ean = $shop_ean; } else { $ean = $value['AREANCODE']; } if ($value['ARHERSTNR'] == '' && $shop_herstnr != '') { $suppliernumber = $shop_herstnr; } else { $suppliernumber = $value['ARHERSTNR']; } if (($value['KOHTEXT'] == '' || trim($value['KOHTEXT']) == "keine Angabe") && $shop_herst != '') { $supplier = $shop_herst; } else { $supplier = $value['KOHTEXT']; } if ($ean != 0 && $ean != '' || !in_array($suppliernumber, $fake_suppliernumber)) { if ($value['Rieck-Bestand'] > 0) { $lagerbestand = $value['Rieck-Bestand']; } else { $lagerbestand = $value['Conrad-Bestand']; } $net_price = number_format($net_price + 0, 2, ',', ''); $art_bezeichnung = str_replace('"', '""', $art_bezeichnung); $art_bezeichnung = str_replace('"', '""', $art_bezeichnung); $art_bezeichnung = str_replace('&', '&', $art_bezeichnung); $supplier = str_replace('&', '&', $supplier); if (key_exists($key, $catpaths) && key_exists($shop, $catpaths[$key])) { $categoriepath = $catpaths[$key][$shop]; } else { $categoriepath = ''; $cats[] = $shopArticleData_hoh[$key]['artikelNr']; $catNbr++; } if ($catNbr == 1000) { $tmpCatArray = getCategories($shop, $cats); if (!empty($tmpCategories)) { $tmpCategories = array_merge($tmpCategories, $tmpCatArray); } else { $tmpCategories = $tmpCatArray; } $catNbr = 0; unset($cats); } $tmpArray = array('ordernumber' => $key, 'suppliernumber' => $suppliernumber, 'ean' => $ean, 'supplier' => $supplier, 'artBez' => $art_bezeichnung, 'artikelNr' => $shopArticleData_hoh[$key]['artikelNr'], 'net_price' => $net_price, 'lagerbestand' => $lagerbestand, 'shop_image' => $shop_image, 'deeplink' => $shop_deeplink, 'shop' => $shop, 'category' => $categoriepath); $tmpContentArray[] = $tmpArray; } } } } if (!empty($cats)) { $tmpCatArray = getCategories($shop, $cats); if (!empty($tmpCategories)) { $tmpCategories = array_merge($tmpCategories, $tmpCatArray); } else { $tmpCategories = $tmpCatArray; } $catNbr = 0; unset($cats); } } $categories[$shop] = $tmpCategories; foreach ($tmpContentArray as $contentValue) { if ($contentValue['category'] != '') { $shop_categorie = $contentValue['category']; } else { if (array_key_exists("'" . $contentValue['artikelNr'] . "'", $categories[$contentValue['shop']])) { $shop_categorie = $categories[$contentValue['shop']]["'" . $contentValue['artikelNr'] . "'"]; writeCategoryPaths($contentValue['ordernumber'], $contentValue['shop'], $shop_categorie); } else { $shop_categorie = $contentValue['shop']; } } $content .= $contentValue['ordernumber'] . '|' . $contentValue['suppliernumber'] . '|' . $contentValue['ean'] . '|' . $contentValue['supplier'] . '|"' . $contentValue['artBez'] . '"|' . $shop_categorie . '|' . $contentValue['net_price'] . '|' . $contentValue['lagerbestand'] . '|' . $contentValue['shop_image'] . '|' . $contentValue['deeplink'] . "\r\n"; } $result = writeCsvFile($content, 'a'); unset($content); return $result; }
/** * Generate scoreboard data based on the cached data in table * 'scorecache_{public,jury}'. If the function is called while * $jury set to true, the scoreboard will always be * current, regardless of the freezetime setting in the contesttable. * * The $filter argument may contain subarrays 'affilid', 'country', * 'categoryid' of values to filter on these. * * This function returns an array (scores, summary, matrix) * containing the following: * * scores[teamid](num_points, total_time, solve_times[], rank, * teamname, categoryid, sortorder, country, affilid) * * matrix[teamid][probid](is_correct, num_submissions, num_pending, time, penalty) * * summary(num_points, total_time, affils[affilid], countries[country], problems[probid] * probid(num_submissions, num_pending, num_correct, best_time_sort[sortorder] ) */ function genScoreBoard($cdata, $jury = FALSE, $filter = NULL) { global $DB; $cid = $cdata['cid']; // Show final scores if contest is over and unfreezetime has been // reached, or if contest is over and no freezetime had been set. // We can compare $now and the dbfields stringwise. $now = now(); $showfinal = !isset($cdata['freezetime']) && difftime($cdata['endtime'], $now) <= 0 || isset($cdata['unfreezetime']) && difftime($cdata['unfreezetime'], $now) <= 0; // contest is active but has not yet started $cstarted = difftime($cdata['starttime'], $now) <= 0; // Don't leak information before start of contest if (!$cstarted && !$jury) { return; } // get the teams, problems and categories $teams = getTeams($filter, $jury, $cdata); $probs = getProblems($cdata); $categs = getCategories($jury); // initialize the arrays we'll build from the data $MATRIX = array(); $SUMMARY = initSummary($probs); $SCORES = initScores($teams); // scorecache_jury is always up to date, scorecache_public might be frozen. if ($jury || $showfinal) { $cachetable = 'scorecache_jury'; } else { $cachetable = 'scorecache_public'; } // Get all stuff from the cached table from this contest $query = "SELECT points, {$cachetable}.* FROM {$cachetable} JOIN contestproblem USING(probid,cid) WHERE cid = %i"; $scoredata = $DB->q($query, $cid); // loop all info the scoreboard cache and put it in our own datastructure while ($srow = $scoredata->next()) { // skip this row if the team or problem is not known by us if (!array_key_exists($srow['teamid'], $teams) || !array_key_exists($srow['probid'], $probs)) { continue; } $penalty = calcPenaltyTime($srow['is_correct'], $srow['submissions']); // fill our matrix with the scores from the database $MATRIX[$srow['teamid']][$srow['probid']] = array('is_correct' => (bool) $srow['is_correct'], 'num_submissions' => $srow['submissions'], 'num_pending' => $srow['pending'], 'time' => $srow['totaltime'], 'penalty' => $penalty); // calculate totals for this team if ($srow['is_correct']) { $SCORES[$srow['teamid']]['num_points'] += $srow['points']; $SCORES[$srow['teamid']]['solve_times'][] = $srow['totaltime']; $SCORES[$srow['teamid']]['total_time'] += $srow['totaltime'] + $penalty; } } // sort the array using our custom comparison function uasort($SCORES, 'cmp'); // loop over all teams to calculate ranks and totals $prevsortorder = -1; foreach ($SCORES as $team => $totals) { // rank, team name, total correct, total time if ($totals['sortorder'] != $prevsortorder) { $prevsortorder = $totals['sortorder']; $rank = 0; // reset team position on switch to different category $prevteam = null; } $rank++; // Use previous' team rank when scores are equal if (isset($prevteam) && cmpscore($SCORES[$prevteam], $totals) == 0) { $SCORES[$team]['rank'] = $SCORES[$prevteam]['rank']; } else { $SCORES[$team]['rank'] = $rank; } $prevteam = $team; // keep summary statistics for the bottom row of our table // The num_points summary is useful only if they're all 1-point problems. $SUMMARY['num_points'] += $totals['num_points']; if (!empty($teams[$team]['affilid'])) { @$SUMMARY['affils'][$totals['affilid']]++; } if (!empty($teams[$team]['country'])) { @$SUMMARY['countries'][$totals['country']]++; } // for each problem foreach (array_keys($probs) as $prob) { // provide default scores when nothing submitted for this team,problem yet if (!isset($MATRIX[$team][$prob])) { $MATRIX[$team][$prob] = array('num_submissions' => 0, 'num_pending' => 0, 'is_correct' => false, 'time' => 0, 'penalty' => 0); } $pdata = $MATRIX[$team][$prob]; $psum =& $SUMMARY['problems'][$prob]; // update summary data for the bottom row @($psum['num_submissions'] += $pdata['num_submissions']); @($psum['num_pending'] += $pdata['num_pending']); @($psum['num_correct'] += $pdata['is_correct'] ? 1 : 0); if ($pdata['is_correct']) { // store per sortorder the first solve time if (!isset($psum['best_time_sort'][$totals['sortorder']]) || $pdata['time'] < $psum['best_time_sort'][$totals['sortorder']]) { @($psum['best_time_sort'][$totals['sortorder']] = $pdata['time']); } } } } return array('matrix' => $MATRIX, 'scores' => $SCORES, 'summary' => $SUMMARY, 'teams' => $teams, 'problems' => $probs, 'categories' => $categs); }
<?php include dirname(__FILE__) . '/../bootstrap/Doctrine.php'; include dirname(__FILE__) . '/../../lib/test/chartSourceUtilityTest.class.php'; $ut = new chartSourceUtilityTest(new sfBrowser()); $t = new lime_test(136, new lime_output_color()); $scenarios = $ut->getBaseScenarios(); $options = array('categories' => getCategories(), 'vehicles' => getVehicles($ut->getUserId('user_gs')), 'user_id' => $ut->getUserId('user_gs')); $params = array('full_history' => false); //foreach ($scenarios as $key => $scenario) { for ($index = 0; $index < 16; $index++) { $scenario = $scenarios[$index]; $y = getYForScenario($ut, $scenario); $x = getXForScenario($ut, $scenario); $fname = 'buildCostPieChartData'; $options = array_merge($options, array('vehicle_display' => $scenario[0])); $g = $ut->runTest($t, $scenario, $fname, $x, $y, $options, $params); } function getYForScenario($ut, $scenario) { $case = $ut->getCase($scenario[0], $scenario[1]); $range = $scenario[2]; $limit = isset($scenario[3]) ? true : false; // categories // [0] => Fuel // [1] => Initial investment // [2] => Leasing // [3] => Tax // [4] => Accessory // [5] => Insurance // [6] => Fine
function printCategories() { $cats = getCategories(); $out = '<select name="categorie">'; foreach ($cats as $cat) { $out .= "<option value='" . htmlsafe($cat[id]) . "' >" . htmlsafe($cat[name]) . "</option>"; } $out .= "</select>"; echo $out . "<br />"; }
function moblog_manage() { global $blogURL; if (Acl::check('group.administrators') && $_SERVER['REQUEST_METHOD'] == 'POST') { Setting::setBlogSettingGlobal('MmsPop3Email', $_POST['pop3email']); Setting::setBlogSettingGlobal('MmsPop3Host', $_POST['pop3host']); Setting::setBlogSettingGlobal('MmsPop3Port', $_POST['pop3port']); Setting::setBlogSettingGlobal('MmsPop3Ssl', !empty($_POST['pop3ssl']) ? 1 : 0); Setting::setBlogSettingGlobal('MmsPop3Username', $_POST['pop3username']); Setting::setBlogSettingGlobal('MmsPop3Password', $_POST['pop3password']); Setting::setBlogSettingGlobal('MmsPop3Visibility', $_POST['pop3visibility']); Setting::setBlogSettingGlobal('MmsPop3Category', $_POST['pop3category']); Setting::setBlogSettingGlobal('MmsPop3Fallbackuserid', getUserId()); Setting::setBlogSettingGlobal('MmsPop3MinSize', 0); Setting::setBlogSettingGlobal('MmsPop3AllowOnly', !empty($_POST['pop3allowonly']) ? 1 : 0); Setting::setBlogSettingGlobal('MmsPop3Allow', $_POST['pop3allow']); Setting::setBlogSettingGlobal('MmsPop3Subject', $_POST['pop3subject']); } $pop3email = Setting::getBlogSettingGlobal('MmsPop3Email', ''); $pop3host = Setting::getBlogSettingGlobal('MmsPop3Host', 'localhost'); $pop3port = Setting::getBlogSettingGlobal('MmsPop3Port', 110); $pop3ssl = Setting::getBlogSettingGlobal('MmsPop3Ssl', 0) ? " checked=1 " : ""; $pop3username = Setting::getBlogSettingGlobal('MmsPop3Username', ''); $pop3password = Setting::getBlogSettingGlobal('MmsPop3Password', ''); $pop3minsize = Setting::getBlogSettingGlobal('MmsPop3MinSize', 0); $pop3category = Setting::getBlogSettingGlobal('MmsPop3Category', 0); $pop3fallheadercharset = Setting::getBlogSettingGlobal('MmsPop3Fallbackcharset', 'euc-kr'); $pop3visibility = Setting::getBlogSettingGlobal('MmsPop3Visibility', '2'); $pop3mmsallowonly = Setting::getBlogSettingGlobal('MmsPop3AllowOnly', '0'); $pop3mmsallow = Setting::getBlogSettingGlobal('MmsPop3Allow', ''); $pop3subject = Setting::getBlogSettingGlobal('MmsPop3Subject', '%Y-%M-%D'); ?> <hr class="hidden" /> <div id="part-setting-editor" class="part"> <h2 class="caption"><span class="main-text"><?php echo _t('MMS 메시지 확인용 메일 환경 설정'); ?> </span></h2> <?php if (!Acl::check("group.administrators")) { ?> <div id="editor-section" class="section"> <dl id="formatter-line" class="line"> <dt><span class="label"><?php echo _t('MMS 수신 이메일'); ?> </span></dt> <dd> <?php if (empty($pop3email)) { ?> <?php echo _t('비공개'); ?> <?php } else { ?> <?php echo $pop3email; ?> <?php } ?> </dd> <dd> <?php if (empty($pop3email)) { ?> <?php echo _t('이동전화에서 보내는 이메일을 수신할 주소가 공개되지 않았습니다'); ?> <?php } else { ?> <?php echo _t('이동전화를 이용하여 위 메일로 이메일을 보내면 블로그에 게시됩니다'); ?> <?php } ?> </dd> </dl> </div> <?php } else { ?> <script type="text/javascript"> function changehost(packedhost) { var h = packedhost.split( ':' ); document.forms['editor-form']['pop3host'].value = h[0]; document.forms['editor-form']['pop3port'].value = h[1]; document.forms['editor-form']['pop3ssl'].checked = !!parseInt(h[2]); } function renderhosts() { var hosts = "<?php echo _t('PREDEFINED POP3 HOSTS'); ?> "; if( hosts == 'PREDEFINED POP3 HOSTS' ) { hosts = "gmail:pop.gmail.com:995:1/hanmail:pop.hanmail.net:995:1/naver:pop.naver.com:110:0/nate:mail.nate.com:110:0"; } hosts = "Localhost:localhost:110:0/" + hosts; hosts = hosts.split('/'); for( var i=0; i<hosts.length; i++ ) { var h = hosts[i]; var n = h.split(':')[0]; var v = h.substr(n.length+1); document.write( "<option value=\""+v+"\">"+n+"</option>" ); } } </script> <form id="editor-form" class="data-inbox" method="post" action="<?php echo $blogURL; ?> /owner/plugin/adminMenu?name=CL_Moblog/moblog_manage"> <div id="editor-section" class="section"> <fieldset class="container"> <legend><?php echo _t('MMS 환경을 설정합니다'); ?> </legend> <dl id="formatter-line" class="line"> <dt><span class="label"><?php echo _t('MMS용 이메일'); ?> </span></dt> <dd> <input type="text" style="width:14em" class="input-text" name="pop3email" value="<?php echo $pop3email; ?> " /> <?php echo _t('(필진에 공개 됩니다. 사진을 찍어 이메일로 보내면 포스팅이 됩니다)'); ?> </dd> </dl> <dl id="formatter-line" class="line"> <dt><span class="label"><?php echo _t('POP3 호스트'); ?> </span></dt> <dd> <input type="text" style="width:14em" class="input-text" name="pop3host" value="<?php echo $pop3host; ?> " /> <select onchange="changehost(this.value)"> <option value=""><?php echo _t('선택하세요'); ?> </option> <script type="text/javascript">renderhosts()</script> </select> </dd> </dl> <dl id="editor-line" class="line"> <dt><span class="label"><?php echo _t('POP3 포트'); ?> </span></dt> <dd> <input type="text" style="width:14em" class="input-text" name="pop3port" value="<?php echo $pop3port; ?> " /> <input type="checkbox" name="pop3ssl" value="1" <?php echo $pop3ssl; ?> /> SSL </dd> </dl> <dl id="editor-line" class="line"> <dt><span class="label"><?php echo _t('POP3 아이디'); ?> </span></dt> <dd> <input type="text" style="width:14em" class="input-text" name="pop3username" value="<?php echo $pop3username; ?> " /> </dd> </dl> <dl id="editor-line" class="line"> <dt><span class="label"><?php echo _t('POP3 비밀번호'); ?> </span></dt> <dd> <input type="password" style="width:14em" class="input-text" name="pop3password" value="<?php echo $pop3password; ?> " /> </dd> </dl> <div class="button-box"> <input type="submit" class="save-button input-button wide-button" value="<?php echo _t('저장하기'); ?> " /> </div> </div> <h2 class="caption"><span class="main-text"><?php echo _t('글 쓰기 환경 설정'); ?> </span></h2> <div id="editor-section" class="section"> <dl id="editor-line" class="line"> <dt><span class="label"><?php echo _t('제목'); ?> </span></dt> <dd> <input type="text" style="width:24em" class="input-text" id="pop3subject" name="pop3subject" value="<?php echo $pop3subject; ?> " /> (<?php echo _t('%Y:년, %M:월, %D:일'); ?> ) <input type="button" value="<?php echo _t("초기화"); ?> " onclick="document.getElementById('pop3subject').value='%Y-%M-%D';return false;" /> </dd> </dl> <dl id="editor-line" class="line"> <dt><span class="label"><?php echo _t('공개여부'); ?> </span></dt> <dd> <span id="status-private" class="status-private"><input type="radio" id="visibility_private" class="radio" name="pop3visibility" value="0"<?php echo $pop3visibility == 0 ? ' checked="checked"' : ''; ?> /><label for="visibility_private"><?php echo _t('비공개'); ?> </label></span> <span id="status-protected" class="status-protected"><input type="radio" id="visibility_protected" class="radio" name="pop3visibility" value="1"<?php echo $pop3visibility == 1 ? ' checked="checked"' : ''; ?> /><label for="visibility_protected"><?php echo _t('보호'); ?> </label></span> <span id="status-public" class="status-public"><input type="radio" id="visibility_public" class="radio" name="pop3visibility" value="2"<?php echo $pop3visibility == 2 ? ' checked="checked"' : ''; ?> /><label for="visibility_public"><?php echo _t('공개'); ?> </label></span> <span id="status-syndicated" class="status-syndicated"><input type="radio" id="visibility_syndicated" class="radio" name="pop3visibility" value="3"<?php echo $pop3visibility == 3 ? ' checked="checked"' : ''; ?> /><label for="visibility_syndicated"><?php echo _t('발행'); ?> </label></span> </dd> </dl> <dl id="editor-line" class="line"> <dt><span class="label"><?php echo _t('분류'); ?> </span></dt> <dd> <select id="category" name="pop3category"> <optgroup class="category" label="<?php echo _t('분류'); ?> "> <?php foreach (getCategories(getBlogId()) as $category) { ?> <?php if ($category['id'] != 0) { ?> <option value="<?php echo $category['id']; ?> " <?php echo $category['id'] == $pop3category ? 'selected' : ''; ?> > <?php echo ($category['visibility'] > 1 ? '' : _t('(비공개)')) . htmlspecialchars($category['name']); ?> </option> <?php } ?> <?php foreach ($category['children'] as $child) { ?> <?php if ($category['id'] != 0) { ?> <option value="<?php echo $child['id']; ?> " <?php echo $child['id'] == $pop3category ? 'selected' : ''; ?> > ― <?php echo ($category['visibility'] > 1 && $child['visibility'] > 1 ? '' : _t('(비공개)')) . htmlspecialchars($child['name']); ?> </option> <?php } ?> <?php } ?> <?php } ?> </optgroup> </select> </dd> </dl> <div class="button-box"> <input type="submit" class="save-button input-button wide-button" value="<?php echo _t('저장하기'); ?> " /> </div> </div> <h2 class="caption"><span class="main-text"><?php echo _t('메일 필터링 설정'); ?> </span></h2> <div id="editor-section" class="section"> <dl id="formatter-line" class="line"> <dt><span class="label"><?php echo _t('허용 목록'); ?> </span></dt> <dd> <input type="radio" id="pop3allowonly" name="pop3allowonly" value="1" <?php echo $pop3mmsallowonly ? 'checked="checked"' : ''; ?> /> <label for="pop3allowonly"><?php echo _t('다음 송신자로부터 전송된 메일만 MMS로 인식하여 처리합니다'); ?> </label> </dd> <dd> <input type="radio" id="pop3allowlist" name="pop3allowonly" value="0" <?php echo $pop3mmsallowonly ? '' : 'checked="checked"'; ?> /> <label for="pop3allowlist"><?php echo _t('다음 송신자로부터 전송된 메일도 MMS로 인식하여 처리합니다'); ?> </label> </dd> <dd> <input type="text" maxlength="128" name="pop3allow" value="<?php echo htmlentities($pop3mmsallow); ?> " style="width:90%" /> </dd> <dd> <?php echo _t('여러 개인 경우 전화번호 혹은 이메일 주소를 쉼표나 공백으로 구별하여 나열합니다'); ?> </dd> <dd> </dd> </dl> <div class="button-box"> <input type="submit" class="save-button input-button wide-button" value="<?php echo _t('저장하기'); ?> " /> </div> </div> </form> <h2 class="caption"><span class="main-text"><?php echo _t('MMS 메시지 테스트'); ?> </span></h2> <div id="editor-section" class="section"> <dl id="formatter-line" class="line"> <dt><span class="label"><?php echo _t('명령'); ?> </span></dt> <dd> <input type="button" class="save-button input-button wide-button" value="<?php echo _t('로그보기'); ?> " onclick="document.getElementById('pop3_debug').src='<?php echo $blogURL; ?> /plugin/moblog/check?check=1&rnd='+((new Date()).getTime())" /> <input type="button" class="save-button input-button wide-button" value="<?php echo _t('시험하기'); ?> " onclick="document.getElementById('pop3_debug').src='<?php echo $blogURL; ?> /plugin/moblog/check?rnd='+((new Date()).getTime())" /> </dd> </dl> </div> <iframe src="about:blank" class="debug_message" id="pop3_debug" style="width:100%; height:400px"> </iframe> <?php } ?> </div> <?php }
function getExportContent() { $fake_suppliernumber = array('No Name', '000', '0000', 'Diverse', '', ' '); $ordernumber = 0; $missing_article = array(); $shop = 'hoh'; $shopArticleData_hoh = getShopArticleData($shop, $missing_article); $mentionArticleData = getMentionArticleData(); // UTF8 Bom writeBom(); /*echo "<pre>"; print_r($mentionArticleData); echo "<pre>"; exit();*/ $count = 0; $content = 'Artikelnummer|Hersteller-Artikelnummer|EAN|Hersteller|Bezeichnung|Kategorie 1|HEK|Lagerbestand|Image|Deep-Link' . "\r\n"; $result = writeCsvFile($content, 'a'); $content = ""; $tmpContentArray = array(); $cats = array(); $catNbr = 0; $tmpCategories = array(); $categories = array(); foreach ($mentionArticleData as $key => $value) { unset($supplier, $suppliernumber, $ean, $art_bezeichnung, $net_price, $shop_ean, $shop_herst, $shop_herstnr, $shop_image, $shop_deeplink, $shop_categorie); $lagerbestand = 0; $shop_art_exists = 0; if ($value['VK_Netto'] > 0) { $net_price = $value['VK_Netto']; } else { if ($value['VK_Brutto'] > 0) { $net_price = $value['VK_Brutto'] / (1 + $value['mwst'] / 100); } else { if ($value['VK_Kalkulation'] > 0 && ($value['MLEKPREIS'] > 0 || $value['AEEKPREIS'] > 0)) { if ($value['Rieck-Bestand'] > 0) { $net_price = $value['MLEKPREIS'] * (1 + $value['VK_Kalkulation'] / 100); } else { $net_price = $value['AEEKPREIS'] * (1 + $value['VK_Kalkulation'] / 100); } } else { $net_price = 0; } } } /*if ( $key == 10184851 ) { echo "<br>Netto: " . $net_price; echo "<br>MLEKPREIS: " . $value['MLEKPREIS']; echo "<br>AEEKPREIS: " . $value['AEEKPREIS']; echo "<pre>"; print_r($shopArticleData_hoh); echo "<pre>"; exit(); }*/ if ($net_price > 0 && $net_price >= $value['MLEKPREIS'] && $net_price >= $value['AEEKPREIS']) { if (array_key_exists($key, $shopArticleData_hoh)) { $shop_art_exists = 1; $shop_ean = $shopArticleData_hoh[$key]['ean']; #$selContent .= iconv('UTF-8', 'ISO-8859-1', $value)."\r\n"; #$art_bezeichnung = iconv('ISO-8859-1', 'UTF-8', $shopArticleData_hoh[$key]['artikelbez']); $art_bezeichnung = $shopArticleData_hoh[$key]['artikelbez']; #$art_bezeichnung = $shopArticleData_hoh[$key]['artikelbez']; $shop_herstnr = $shopArticleData_hoh[$key]['suppliernumber']; $shop_herst = $shopArticleData_hoh[$key]['supplier']; $shop_image = $shopArticleData_hoh[$key]['imageURL']; $shop_deeplink = $shopArticleData_hoh[$key]['URL']; } else { $missing_article[] = $key; } if ($shop_art_exists == 1) { if ($value['AREANCODE'] == 0 && $shop_ean != 0 || $value['AREANCODE'] == '' && $shop_ean != '') { $ean = $shop_ean; } else { $ean = $value['AREANCODE']; } if ($value['ARHERSTNR'] == '' && $shop_herstnr != '') { $suppliernumber = $shop_herstnr; } else { $suppliernumber = $value['ARHERSTNR']; } if (($value['KOHTEXT'] == '' || trim($value['KOHTEXT']) == "keine Angabe") && $shop_herst != '') { $supplier = $shop_herst; } else { $supplier = $value['KOHTEXT']; } /* if ( $key == 100073412 ) { echo "<br>Netto: " . $net_price; echo "<br>MLEKPREIS: " . $value['MLEKPREIS']; echo "<br>AEEKPREIS: " . $value['AEEKPREIS']; echo "<br>******************"; echo "<br>EAN: " . $ean; echo "<br>suppliernumber: " . $suppliernumber; echo "<pre>"; print_r($catNbr); echo "<pre>"; exit(); }*/ if ($ean != 0 && $ean != '' || !in_array($suppliernumber, $fake_suppliernumber)) { if ($value['Rieck-Bestand'] > 0) { $lagerbestand = $value['Rieck-Bestand']; } else { $lagerbestand = $value['Conrad-Bestand']; } $net_price = number_format($net_price + 0, 2, ',', ''); $art_bezeichnung = str_replace('"', '""', $art_bezeichnung); $art_bezeichnung = str_replace('"', '""', $art_bezeichnung); $art_bezeichnung = str_replace('&', '&', $art_bezeichnung); $supplier = str_replace('&', '&', $supplier); $supplier = iconv('ISO-8859-1', 'UTF-8', $supplier); $cats[] = $shopArticleData_hoh[$key]['artikelNr']; $catNbr++; /*if ( $key == 100073412 ) { echo "<br>Netto: " . $net_price; echo "<br>MLEKPREIS: " . $value['MLEKPREIS']; echo "<br>AEEKPREIS: " . $value['AEEKPREIS']; echo "<br>******************"; echo "<br>EAN: " . $ean; echo "<br>suppliernumber: " . $suppliernumber; echo "<pre>"; print_r($catNbr); echo "<pre>"; exit(); }*/ if ($catNbr == 1000) { $tmpCatArray = getCategories($shop, $cats); if (!empty($tmpCategories)) { $tmpCategories = array_merge($tmpCategories, $tmpCatArray); } else { $tmpCategories = $tmpCatArray; } $catNbr = 0; unset($cats); } $tmpArray = array('ordernumber' => $key, 'suppliernumber' => $suppliernumber, 'ean' => $ean, 'supplier' => $supplier, 'artBez' => $art_bezeichnung, 'artikelNr' => $shopArticleData_hoh[$key]['artikelNr'], 'net_price' => $net_price, 'lagerbestand' => $lagerbestand, 'shop_image' => $shop_image, 'deeplink' => $shop_deeplink, 'shop' => $shop); $tmpContentArray[] = $tmpArray; } } } } /*echo "<pre>"; print_r($tmpContentArray); echo "<pre>";*/ /*echo "<br>***************************** missing ******************************<br>"; echo "<pre>"; print_r($missing_article); echo "<pre>"; exit('aus');*/ if (!empty($cats)) { $tmpCatArray = getCategories($shop, $cats); if (!empty($tmpCategories)) { $tmpCategories = array_merge_recursive($tmpCategories, $tmpCatArray); } else { $tmpCategories = $tmpCatArray; } $catNbr = 0; unset($cats); } $categories[$shop] = $tmpCategories; foreach ($tmpContentArray as $contentValue) { /*if ($contentValue['ordernumber'] == 100073412) { echo "<pre>"; print_r($contentValue); echo "<pre>"; }*/ if (array_key_exists("'" . $contentValue['artikelNr'] . "'", $categories[$contentValue['shop']])) { if ($contentValue['ordernumber'] == 100073412) { echo "<br> array found"; } $shop_categorie = $categories[$contentValue['shop']]["'" . $contentValue['artikelNr'] . "'"]; } else { if ($contentValue['ordernumber'] == 100073412) { echo "<br> array not found"; } $shop_categorie = $contentValue['shop']; } $content .= $contentValue['ordernumber'] . '|' . $contentValue['suppliernumber'] . '|' . $contentValue['ean'] . '|' . $contentValue['supplier'] . '|"' . $contentValue['artBez'] . '"|' . $shop_categorie . '|' . $contentValue['net_price'] . '|' . $contentValue['lagerbestand'] . '|' . $contentValue['shop_image'] . '|' . $contentValue['deeplink'] . "\r\n"; } #echo "<pre>"; #print_r($tmpContentArray); #echo "<pre>"; $result = writeCsvFile($content, 'a'); #exit("aus"); unset($content, $tmpCategories, $tmpContentArray, $shopArticleData_hoh); if (!empty($missing_article)) { $shop = 'getgoods'; $content = ''; $tmpCategories = array(); $tmpContentArray = array(); $shopArticleData_hoh = getShopArticleData($shop, $missing_article); foreach ($mentionArticleData as $key => $value) { unset($supplier, $suppliernumber, $ean, $art_bezeichnung, $net_price, $shop_ean, $shop_herst, $shop_herstnr, $shop_image, $shop_deeplink, $shop_categorie); $lagerbestand = 0; $shop_art_exists = 0; if ($value['VK_Netto'] > 0) { $net_price = $value['VK_Netto']; } else { if ($value['VK_Brutto'] > 0) { $net_price = $value['VK_Brutto'] / (1 + $value['mwst'] / 100); } else { if ($value['VK_Kalkulation'] > 0 && ($value['MLEKPREIS'] > 0 || $value['AEEKPREIS'] > 0)) { if ($value['Rieck-Bestand'] > 0) { $net_price = $value['MLEKPREIS'] * (1 + $value['VK_Kalkulation'] / 100); } else { $net_price = $value['AEEKPREIS'] * (1 + $value['VK_Kalkulation'] / 100); } } else { $net_price = 0; } } } if ($net_price > 0 && $net_price >= $value['MLEKPREIS'] && $net_price >= $value['AEEKPREIS'] && in_array($key, $missing_article)) { if (array_key_exists($key, $shopArticleData_hoh)) { $shop_art_exists = 1; $shop_ean = $shopArticleData_hoh[$key]['ean']; $art_bezeichnung = $shopArticleData_hoh[$key]['artikelbez']; $shop_herstnr = $shopArticleData_hoh[$key]['suppliernumber']; $shop_herst = $shopArticleData_hoh[$key]['supplier']; $shop_image = $shopArticleData_hoh[$key]['imageURL']; $shop_deeplink = $shopArticleData_hoh[$key]['URL']; } else { $missing_article[] = $key; } if ($shop_art_exists == 1) { if ($value['AREANCODE'] == 0 && $shop_ean != 0 || $value['AREANCODE'] == '' && $shop_ean != '') { $ean = $shop_ean; } else { $ean = $value['AREANCODE']; } if ($value['ARHERSTNR'] == '' && $shop_herstnr != '') { $suppliernumber = $shop_herstnr; } else { $suppliernumber = $value['ARHERSTNR']; } if (($value['KOHTEXT'] == '' || trim($value['KOHTEXT']) == "keine Angabe") && $shop_herst != '') { $supplier = $shop_herst; } else { $supplier = $value['KOHTEXT']; } if ($ean != 0 && $ean != '' || !in_array($suppliernumber, $fake_suppliernumber)) { if ($value['Rieck-Bestand'] > 0) { $lagerbestand = $value['Rieck-Bestand']; } else { $lagerbestand = $value['Conrad-Bestand']; } $net_price = number_format($net_price + 0, 2, ',', ''); $art_bezeichnung = str_replace('"', '""', $art_bezeichnung); $art_bezeichnung = str_replace('"', '""', $art_bezeichnung); $art_bezeichnung = str_replace('&', '&', $art_bezeichnung); $supplier = str_replace('&', '&', $supplier); $cats[] = $shopArticleData_hoh[$key]['artikelNr']; $catNbr++; if ($catNbr == 1000) { $tmpCatArray = getCategories($shop, $cats); if (!empty($tmpCategories)) { $tmpCategories = array_merge($tmpCategories, $tmpCatArray); } else { $tmpCategories = $tmpCatArray; } $catNbr = 0; unset($cats); } $tmpArray = array('ordernumber' => $key, 'suppliernumber' => $suppliernumber, 'ean' => $ean, 'supplier' => $supplier, 'artBez' => $art_bezeichnung, 'artikelNr' => $shopArticleData_hoh[$key]['artikelNr'], 'net_price' => $net_price, 'lagerbestand' => $lagerbestand, 'shop_image' => $shop_image, 'deeplink' => $shop_deeplink, 'shop' => $shop); $tmpContentArray[] = $tmpArray; } } } } if (!empty($cats)) { $tmpCatArray = getCategories($shop, $cats); if (!empty($tmpCategories)) { $tmpCategories = array_merge($tmpCategories, $tmpCatArray); } else { $tmpCategories = $tmpCatArray; } $catNbr = 0; unset($cats); } } $categories[$shop] = $tmpCategories; foreach ($tmpContentArray as $contentValue) { if (array_key_exists("'" . $contentValue['artikelNr'] . "'", $categories[$contentValue['shop']])) { $shop_categorie = $categories[$contentValue['shop']]["'" . $contentValue['artikelNr'] . "'"]; } else { $shop_categorie = $contentValue['shop']; } $content .= $contentValue['ordernumber'] . '|' . $contentValue['suppliernumber'] . '|' . $contentValue['ean'] . '|' . $contentValue['supplier'] . '|"' . $contentValue['artBez'] . '"|' . $shop_categorie . '|' . $contentValue['net_price'] . '|' . $contentValue['lagerbestand'] . '|' . $contentValue['shop_image'] . '|' . $contentValue['deeplink'] . "\r\n"; } $result = writeCsvFile($content, 'a'); unset($content); return $result; }
function showCategoryTree() { $categories = getCategories(); header('Content-type:text/json;charset=utf-8'); echo json_encode($categories, JSON_UNESCAPED_UNICODE); }
<?php require_once 'PHP/fonctions.php'; $categories = getCategories(); ?> <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Kogn Bi, vos annonces à portée de main</title> <link href='http://fonts.googleapis.com/css?family=Maven+Pro:400,700' rel='stylesheet' type='text/css'> <link rel="stylesheet" type="text/css" href="css/bootstrap.css"> <link rel="stylesheet" type="text/css" href="css/bootstrap-theme.css"> <link rel="stylesheet" type="text/css" href="css/font-awesome.css"> <link rel="stylesheet" type="text/css" href="css/default.css"> <link rel="stylesheet" type="text/css" href="css/responsive.css"> <link rel="stylesheet" type="text/css" href="css/star-rating.css"> </head> <body> <?php include_once 'inclusions/tete.php'; include_once 'inclusions/search_bar.php'; ?>
<?php include_once "Database.php"; $cmd = isset($_REQUEST["cmd"]) ? $_REQUEST["cmd"] : false; // no command? if (!$cmd) { echo '{"success":false,"data" => array ( "msg" => "No command")'; exit; } switch ($cmd) { case "getCategories": $arrCategory = getCategories(); if (!$arrCategory) { $response = array("success" => false, "data" => array("msg" => "error")); } else { $response = array("success" => true, "data" => array("categories" => $arrCategory)); } break; } header("Content-Type: application/json"); echo json_encode($response); //////////////// // FUNCTIONS //////////////// function getCategories() { @($user = $_SESSION[SESSION_USER_ID]); @($foreignLng = $_SESSION[SESSION_FOREIGN_LANG]); $db = new Database(); $db->open(); // TODO validation