function get_project($category, $name) { $projects = load_projects(); $categories = load_categories(); if (is_numeric($category)) { foreach ($projects as $project) { if ($project['category'] == $category && $project['name'] == $name) { return $project; } } } else { foreach ($projects as $project) { if ($categories[$project['category']] == $category && $project['name'] == $name) { return $project; } } } }
function create_report_name() { checkPerm('mod'); require_once $GLOBALS['where_lms'] . '/admin/modules/report/class.report.php'; //reportbox class require_once $GLOBALS['where_lms'] . '/lib/lib.report.php'; require_once _base_ . '/lib/lib.form.php'; load_categories(); $lang =& DoceboLanguage::createInstance('report'); $step_index = 0; //$GLOBALS['page']->add( get_page_title($step_index) ); $_SESSION['report_tempdata'] = array(); $page_title = getTitleArea(array('index.php?modname=public_report_admin&op=reportlist' => $lang->def('_REPORT'), $lang->def('_NEW')), 'report'); $GLOBALS['page']->add($page_title . '<div class="std_block">', 'content'); $error = Get::req('err', DOTY_STRING, false); switch ($error) { case 'noname': $GLOBALS['page']->add(getErrorUi($lang->def('_REPORT_NONAME'))); break; } $temp = array(); foreach ($GLOBALS['report_categories'] as $key => $value) { $temp[$key] = $lang->def($value); } $GLOBALS['page']->add(Form::openForm('repcat_form', 'index.php?modname=public_report_admin&op=create_rows') . Form::getHidden('set_category', 'set_category', 1) . Form::getTextField($lang->def('_NAME'), 'report_name', 'report_name', '200') . Form::getDropDown($lang->def('_SELECT_REPORT_CATEGORY'), '', 'id_report', $temp) . Form::openButtonSpace() . Form::getButton('', 'cat_forward', $lang->def('_NEXT'), false) . Form::getButton('', 'cat_undo', $lang->def('_UNDO'), false) . Form::closeButtonSpace() . Form::closeForm(), 'content'); /*$lang->def('_REPORT_SCHEDMAN');$lang->def('_REPORT_SCHEDMAN_DESC');*/ $GLOBALS['page']->add('</div>', 'content'); }
<?php $categories = load_categories(); $projects = load_projects(); if (isset($_POST['method'])) { if ($_POST['method'] == 1 && isset($_POST['title']) && isset($_POST['description']) && isset($_POST['keywords']) && isset($_POST['author'])) { $settings = merge($settings, 'settings', array('metaTitle' => htmlspecialchars($_POST['title']), 'metaDescription' => htmlspecialchars($_POST['description']), 'metaKeywords' => htmlspecialchars($_POST['keywords']), 'metaAuthor' => htmlspecialchars($_POST['author']), 'metaLanguage' => htmlspecialchars($_POST['language'])), PP_MESSAGE_METACHANGED); } else { if ($_POST['method'] == 2) { $settings = merge($settings, 'settings', isset($_POST['enable']) ? array('adflyUse' => true, 'adflyId' => htmlspecialchars($_POST['id'])) : array('adflyUse' => false), PP_MESSAGE_ADFLYCHANGED); } else { if ($_POST['method'] == 3) { $categories = merge($categories, 'categories', array(htmlspecialchars($_POST['name'])), PP_MESSAGE_CATEGORYADDED); } else { if ($_POST['method'] == 4) { if (count($categories) == 1) { echo message(PP_MESSAGE_CANNOTREMOVE, 'alert-danger'); } else { $categories = remove($categories, 'categories', $_POST['category'], PP_MESSAGE_CATEGORYREMOVED); $projects_changed = false; for ($i = 0; $i < count($projects); $i++) { if ($projects[$i]['category'] != $_POST['category']) { continue; } $projects = remove($projects, null, $i, null, false); $projects_changed = true; } if ($projects_changed) { finish($projects, 'projects', null); } }
function report_modify_name() { checkPerm('mod'); require_once _lms_ . '/admin/modules/report/class.report.php'; //reportbox class require_once _lms_ . '/lib/lib.report.php'; //require_once('report_categories.php'); load_categories(); $lang =& DoceboLanguage::createInstance('report'); $idrep = Get::req('modid', DOTY_INT, false); //if (!idrep) Util::jump_to(initial page ... ) $page_title = getTitleArea(array('index.php?modname=report&op=reportlist' => $lang->def('_REPORT'), $lang->def('_MOD')), 'report'); cout($page_title . '<div class="std_block">'); $info = get_update_info(); //if($info) cout( getInfoUi($info) ); $box = new ReportBox('report_modify_name'); $box->title = $lang->def('_MOD'); $box->description = false; $box->body = Form::openForm('repcat_form', 'index.php?modname=report&op=modify_rows&modid=' . $idrep) . Form::getHidden('mod_name', 'mod_name', 1); $box->body .= Form::getTextField($lang->def('_NAME'), 'report_name', 'report_name', '200', getReportNameById($idrep)); $box->body .= Form::openButtonSpace() . Form::getButton('', '', $lang->def('_NEXT')) . Form::closeButtonSpace() . Form::closeForm(); cout($box->get()); cout('</div>', 'content'); }
function merlion_page() { $mes = get_option('merlion_current_download'); $last = time() - get_option('merlion_last_item_add'); if ($last > 6000) { $mes = ''; } if ($mes) { echo "<div id='message' class='error'><p>Идет загрузка {$mes}</p></div>"; } $err = get_option('merlion_image_error'); if ($err) { echo $err; } update_option('merlion_image_error', ''); //echo '<pre>'; print_r(_get_cron_array());echo '</pre>'; //$next_update = wp_next_scheduled( 'merlion_update_hook' ); //echo date('d-m-Y H:i:s', $next_update); $saved_cats = get_option('merlion_cat'); $saved_subcats = get_option('merlion_subcat'); $saved_groups = get_option('merlion_group'); if (isset($_POST["save_merlion"]) && $_POST["save_merlion"]) { if ($saved_cats != $_POST['cat']) { update_option('merlion_cat', $_POST['cat']); $saved_cats = $_POST['cat']; } if ($saved_subcats != $_POST['subcat']) { update_option('merlion_subcat', $_POST['subcat']); $saved_subcats = $_POST['subcat']; } if ($saved_groups != $_POST['group']) { update_option('merlion_group', $_POST['group']); $saved_groups = $_POST['group']; } update_option('merlion_selected_shipment', $_POST['ships']); update_option('merlion_article', array('prefix' => $_POST['prefix'], 'suffix' => $_POST['suffix'])); $time_diff = current_time('timestamp') - current_time('timestamp', 1); //текущее местное время блога - время UTC $time_update = mktime($_POST['update_hour'], $_POST['update_minute']); update_option('merlion_update', array('need' => isset($_POST["need_update"]) ? $_POST['need_update'] : '', 'type' => $_POST['time'], 'time' => $time_update)); if (isset($_POST["need_update"]) && $_POST['need_update']) { if (isset($_POST["update_day"]) && $_POST['update_day']) { $dow = date('N', $time_update); $diff = $_POST['update_day'] - $dow; $time_update += $diff * 24 * 60 * 60; } //echo date('d-m-Y H:i:s', $time_update); $next_update = wp_next_scheduled('merlion_update_hook'); if (!$next_update) { wp_schedule_event($time_update - $time_diff, $_POST['time'], 'merlion_update_hook'); } else { wp_unschedule_event($next_update, 'merlion_update_hook'); wp_schedule_event($time_update - $time_diff, $_POST['time'], 'merlion_update_hook'); } } else { $next_update = wp_next_scheduled('merlion_update_hook'); if ($next_update) { wp_unschedule_event($next_update, 'merlion_update_hook'); } } } if (isset($_POST["update_categories"]) && $_POST["update_categories"]) { load_categories('All'); } /*if (isset($_POST["download_properties"]) && $_POST["download_properties"]) { $mes = load_properties_by_cat(); } if (isset($_POST["download_images"]) && $_POST["download_images"]) { $mes = load_images_by_cat(); } */ if (isset($_POST["download_items"]) && $_POST["download_items"]) { $mes = load_items_by_cat(); } if (isset($_POST["shipment_download"]) && $_POST["shipment_download"]) { set_shipments_methods(); } $categories = get_categories(array('taxonomy' => 'product_cat', 'hide_empty' => false, 'parent' => 0)); ?> <form id='cat_choice' method='post'> <h3>Настройки</h3> <table class='form-table'> <tbody> <tr> <th> <label for='categories'>Категории</label> <span class='tip'>Выберите категории для загрузки данных о товарах</span> </th> <td> <div id="categories"> <div> <ul id="tree"> <?php foreach ($categories as $cat) { $child_cat = get_categories(array('taxonomy' => 'product_cat', 'hide_empty' => false, 'parent' => $cat->term_id)); //echo "<li><pre>"; print_r($child_cat); echo "</li></pre>"; $checked = ''; if ($saved_cats) { if (array_key_exists($cat->term_id, $saved_cats)) { $checked = 'checked = "true"'; } } echo "<li><label><input type='checkbox'" . $checked . " name='cat[" . $cat->term_id . "]' value='" . $cat->slug . "'>" . $cat->name . "</label>"; if ($child_cat) { echo "<ul>"; foreach ($child_cat as $child) { $second_child = get_categories(array('taxonomy' => 'product_cat', 'hide_empty' => false, 'parent' => $child->term_id)); $checked = ''; if ($saved_subcats) { if (array_key_exists($child->term_id, $saved_subcats)) { $checked = 'checked = "true"'; } } echo "<li><label><input type='checkbox' " . $checked . " name='subcat[" . $child->term_id . "]' value='" . $child->slug . "'>" . $child->name . "</label>"; if ($second_child) { echo "<ul>"; foreach ($second_child as $second) { $checked = ''; if ($saved_groups) { if (array_key_exists($second->term_id, $saved_groups)) { $checked = 'checked = "true"'; } } echo "<li><label><input type='checkbox' " . $checked . " name='group[" . $second->term_id . "]' value='" . $second->slug . "'>" . $second->name . "</label></li>"; } echo "</ul>"; } echo "</li>"; } echo "</ul>"; } echo "</li>"; } ?> </ul> </div> </div> </td> </tr> <tr> <th> <label for='shipments'>Методы доставки</label> <span class='tip'>Если список методов не отображается, нажмите кнопку "Обновить методы" внизу страницы</span> </th> <td> <div id='shipments'> <ul> <?php $shipments = get_option('merlion_shipment'); $selected_shipment = get_option('merlion_selected_shipment'); if ($shipments) { foreach ($shipments as $key => $value) { $checked = ''; if ($selected_shipment) { if (in_array($key, $selected_shipment)) { $checked = 'checked="true"'; } } echo "<li><input type='checkbox' " . $checked . " name='ships[]' value='" . $key . "'><span>" . $value . "</span></li>"; } } ?> </ul> </div> </td> </tr> <tr> <?php $opt = get_option('merlion_article'); if ($opt) { $pre = $opt['prefix']; $suf = $opt['suffix']; } ?> <th> <label for='article'>Артикул</label> </th> <td> <div id='article'> <label for='prefix'>Префикс</label><input type="text" name="prefix" value='<?php echo $pre; ?> ' id='prefix'><br /> <label for='suffix'>Суффикс</label><input type="text" name="suffix" value='<?php echo $suf; ?> ' id='suffix'><br /> <span>Пример: </span> <span id='exampleArticle'><?php echo $pre; ?> 123456<?php echo $suf; ?> </span> </div> </td> </tr> <tr> <th> <label for='update'>Обновление товаров по времени</label> </th> <td> <div id='update'> <?php $update_opt = get_option('merlion_update'); if ($update_opt) { $need_update = $update_opt['need'] ? 'checked="true"' : ''; $selected = $update_opt['type'] == 'hourly' ? 'selected' : ''; } ?> <input type="checkbox" <?php echo $need_update; ?> name="need_update" id="need_update"> <label for="need_update">Обновлять автоматически</label><br /> <select name="time" id='time'> <option value='hourly' <?php echo $selected; ?> id='hourly'>Каждый час</option> <?php if ($update_opt) { $selected = $update_opt['type'] == 'twicedaily' ? 'selected' : ''; } ?> <option value='twicedaily' <?php echo $selected; ?> id='twicedaily'>Дважды в день</option> <?php if ($update_opt) { $selected = $update_opt['type'] == 'daily' ? 'selected' : ''; } ?> <option value='daily' <?php echo $selected; ?> id='daily'>Ежедневно</option> <?php if ($update_opt) { $selected = $update_opt['type'] == 'weekly' ? 'selected' : ''; } ?> <option value='weekly' <?php echo $selected; ?> id='weekly'>Еженедельно</option> </select> </div> </td> </tr> <tr> <th> <label for='update_time'>Время начала</label> </th> <td> <div id='update_time'> <select name='update_hour'> <?php if ($update_opt) { $hour = date('H', $update_opt['time']); $minute = date('i', $update_opt['time']); $day_of_week = date('N', $update_opt['time']); } for ($i = 0; $i < 24; $i++) { if ($hour) { $selected = $hour == $i ? 'selected' : ''; } echo "<option value='" . $i . "' " . $selected . ">" . date("H", mktime($i)) . "</option>"; } ?> </select> <select name='update_minute'> <?php for ($i = 0; $i < 60; $i++) { if ($minute) { $selected = $minute == $i ? 'selected' : ''; } echo "<option value='" . $i . "' " . $selected . ">" . date("i", mktime(0, $i)) . "</option>"; } ?> </select> </div> </td> </tr> <tr> <?php if ($update_opt && $update_opt['type'] == 'weekly') { $visibility = 'visible'; } else { $visibility = 'hidden'; } ?> <th> <label for='update_day' style="visibility:<?php echo $visibility; ?> " id="ldow">День недели</label> </th> <td> <select name='update_day' id='update_day' style="visibility:<?php echo $visibility; ?> "> <?php if ($day_of_week) { $selected = $day_of_week == 1 ? 'selected' : ''; } ?> <option value='1' <?php echo $selected; ?> >Понедельник</option> <?php if ($day_of_week) { $selected = $day_of_week == 2 ? 'selected' : ''; } ?> <option value='2' <?php echo $selected; ?> >Вторник</option> <?php if ($day_of_week) { $selected = $day_of_week == 3 ? 'selected' : ''; } ?> <option value='3' <?php echo $selected; ?> >Среда</option> <?php if ($day_of_week) { $selected = $day_of_week == 4 ? 'selected' : ''; } ?> <option value='4' <?php echo $selected; ?> >Четверг</option> <?php if ($day_of_week) { $selected = $day_of_week == 5 ? 'selected' : ''; } ?> <option value='5' <?php echo $selected; ?> >Пятница</option> <?php if ($day_of_week) { $selected = $day_of_week == 6 ? 'selected' : ''; } ?> <option value='6' <?php echo $selected; ?> >Суббота</option> <?php if ($day_of_week) { $selected = $day_of_week == 7 ? 'selected' : ''; } ?> <option value='7' <?php echo $selected; ?> >Воскресенье</option> </select> </div> </td> </tr> <tr> <th> <label>Время последнего обновления</label> </th> <td><?php echo get_option('merlion_last_update'); ?> </td> </tr> <tr><th></th> <td> <input type='hidden' name='save_merlion' value='true'> <input type='submit' value='Сохранить' class='button button-primary button-submit'> </td> </tr> </tbody> </table> </form> <table class='form-table' style="display:<?php echo $mes ? 'none' : 'block'; ?> ;" > <tr> <th> <form method='post'> <input type='hidden' name='download_items' value='true'> <input type='submit' value='Загрузить товары' class='button button-primary button-submit'> </form> </th> <td> <label>Загрузить данные о товарах</label> <span class='tip'>Убедитесь, что выбраны необходимые категории и методы отгрузки товара, а также, что все изменения сохранены</span> </td> </tr> <!--<tr> <th> <form method='post'> <input type='hidden' name='download_properties' value='true'> <input type='submit' value='Загрузить характеристики' class='button button-primary button-submit'> </form> </th> <td> <label>Загрузить характеристики товаров</label> <span class='tip'>Убедитесь, что выбраны необходимые категории, а также, что все изменения сохранены</span> </td> </tr> <tr> <th> <form method='post'> <input type='hidden' name='download_images' value='true'> <input type='submit' value='Загрузить изображения' class='button button-primary button-submit'> </form> </th> <td> <label>Загрузить изображения</label> <span class='tip'>Убедитесь, что выбраны необходимые категории, а также, что все изменения сохранены</span> </td> </tr>--> <tr> <th> <form method='post'> <input type='hidden' name='update_categories' value='true'> <input type='submit' value='Обновить категории' class='button button-primary button-submit'> </form> </th> <td> <label>Обновить список категорий</label> </td> </tr> <tr> <th> <form method='post'> <input type='hidden' name='shipment_download' value='true'> <input type='submit' value='Обновить методы' class='button button-primary button-submit'> </form> </th> <td> <label>Обновить список доступных методов доставки</label> </td> </tr> </table> <?php //echo "<pre>"; print_r($saved_cats); echo "</pre>"; //echo "<pre>"; print_r($saved_subcats); echo "</pre>"; //echo "<pre>"; print_r($saved_groups); echo "</pre>"; }