Ejemplo n.º 1
0
 public function index()
 {
     $corpCodes = explode(',', env('CORPS'));
     $emps = HRS_Employee::findByCorps($corpCodes);
     $corps = Processor::getArrayResult(Processor::table('FAS_Corp')->select('Name, Code')->whereIn('Code', $corpCodes));
     $campaigns = Campaign::findValid();
     return view('report.ctilayout.index', ['corps' => $corps, 'empCorpGroups' => array_group($emps, 'FName'), 'campaigns' => $campaigns]);
 }
Ejemplo n.º 2
0
/**
 * 时间验证
 * @name verify_timeline
 * @access private
 * @author lijiaying
 * @category hogesoft
 * @copyright hogesoft
 * @param $starttime array 开始时间
 * @param $endtime array 结束时间
 * @return true or false 
 */
function verify_timeline($starttime, $endtime, $date)
{
    $return = array_group($starttime, $endtime, $date);
    for ($i = 1, $c = count($return); $i < $c; $i++) {
        if ($return[$i] - $return[$i - 1] < 0) {
            return false;
        }
    }
    return true;
}
Ejemplo n.º 3
0
 public function testGroup()
 {
     // arrange
     $array = array(array('id' => 1, 'weekday' => 'Sun'), array('id' => 2, 'weekday' => 'Sun'), array('id' => 3, 'weekday' => 'Sun'), array('id' => 4, 'weekday' => 'Wed'));
     // act
     $grouped = array_group($array, function ($element) {
         return $element['weekday'];
     });
     // assert
     $expected = array('Sun' => array(array('id' => 1, 'weekday' => 'Sun'), array('id' => 2, 'weekday' => 'Sun'), array('id' => 3, 'weekday' => 'Sun')), 'Wed' => array(array('id' => 4, 'weekday' => 'Wed')));
     $this->assertEquals($expected, $grouped);
 }
/**
 * Отдает HTML для предложений фрилансеров Сделаю
 * 
 * @param  object $objResponse xajaxResponse
 * @param  string $rec_id идентификатор записи
 * @param  string $rec_type тип записи
 * @param  array $aParams массив дополнительных параметров
 * @return string
 */
function _admEditSdelauParseForm(&$objResponse, $rec_id = '', $rec_type = '', $aParams = array())
{
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/users.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/freelancer_offers.php';
    $oFreelancerOffers = new freelancer_offers();
    $offer = $oFreelancerOffers->getOfferById($rec_id, false);
    $objUser = new users();
    $objUser->GetUserByUID($offer['user_id']);
    // разделы
    $categories = professions::GetAllGroupsLite();
    $professions = professions::GetAllProfessions();
    array_group($professions, 'groupid');
    $professions[0] = array();
    ob_start();
    include_once $_SERVER['DOCUMENT_ROOT'] . '/user/adm_edit_tpl/sdelau.php';
    $sHtml = ob_get_contents();
    ob_end_clean();
    // текст
    $sOnReady = "if(\$('adm_edit_msg')) \$('adm_edit_msg').set('value', (\$('adm_edit_msg_source')? \$('adm_edit_msg_source').get('value') : null));";
    $objResponse->assign('h4_adm_edit', 'innerHTML', 'Редактировать предложение');
    $objResponse->assign('div_adm_edit', 'innerHTML', $sHtml);
    $objResponse->script($sOnReady);
    $objResponse->script("\$('div_adm_reason').setStyle('display', 'none');");
    $objResponse->script("adm_edit_content.editMenuItems = ['', 'Основное'];");
    $objResponse->script('adm_edit_content.edit();');
    $objResponse->script('xajax_getAdmEditReasons(' . admin_log::ACT_ID_EDIT_SDELAU . ');');
}
Ejemplo n.º 5
0
 /**
  * Изменить информацию о бюджете проекта
  *
  * @param   integer $prj_id         ID проекта
  * @param   float   $prj_cost       Стоимость
  * @param   integer $prj_currency   Валюта
  * @param   integer $prj_costby     Тип стоимости(за час/проект/месяц)
  * @param   boolean $prj_agreement  true - стоимость по договоренности
  * @return  array                   информация о бюджете проекта
  */
 function updateBudget($prj_id, $prj_cost, $prj_currency, $prj_costby, $prj_agreement)
 {
     global $DB;
     if ($prj_agreement) {
         $prj_cost = 0;
         $prj_currency = 0;
         $prj_costby = 0;
         $prj_budget_type = 0;
     } else {
         $prj_cost = floatval($prj_cost);
         $prj_currency = intval($prj_currency);
         $prj_costby = intval($prj_costby);
         $prj_budget_type = 0;
         require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/professions.php";
         $categories = professions::GetAllGroupsLite();
         $professions = professions::GetAllProfessions();
         array_group($professions, 'groupid');
         $professions[0] = array();
         $professions_cost = array();
         $professions_cost['prj'] = array();
         $professions_cost['hour'] = array();
         $professions_cost['prj']['min'] = array();
         $professions_cost['prj']['avg'] = array();
         $professions_cost['prj']['max'] = array();
         $professions_cost['hour']['min'] = array();
         $professions_cost['hour']['avg'] = array();
         $professions_cost['hour']['max'] = array();
         foreach ($categories as $cat) {
             $professions_cost['prj']['min'][$cat['id']] = array();
             $professions_cost['prj']['avg'][$cat['id']] = array();
             $professions_cost['prj']['max'][$cat['id']] = array();
             $professions_cost['hour']['min'][$cat['id']] = array();
             $professions_cost['hour']['avg'][$cat['id']] = array();
             $professions_cost['hour']['max'][$cat['id']] = array();
             $ncount_prj = 0;
             $ncount_hour = 0;
             $nsum_min_prj = 0;
             $nsum_max_prj = 0;
             $nsum_avg_prj = 0;
             $nsum_min_hour = 0;
             $nsum_max_hour = 0;
             $nsum_avg_hour = 0;
             if (!is_array($professions[$cat['id']])) {
                 continue;
             }
             foreach ($professions[$cat['id']] as $subcat) {
                 $professions_cost['hour']['min'][$cat['id']][$subcat['id']] = $subcat['min_cost_hour'];
                 $professions_cost['hour']['avg'][$cat['id']][$subcat['id']] = $subcat['avg_cost_hour'];
                 $professions_cost['hour']['max'][$cat['id']][$subcat['id']] = $subcat['max_cost_hour'];
                 $professions_cost['prj']['min'][$cat['id']][$subcat['id']] = $subcat['min_cost_prj'];
                 $professions_cost['prj']['avg'][$cat['id']][$subcat['id']] = $subcat['avg_cost_prj'];
                 $professions_cost['prj']['max'][$cat['id']][$subcat['id']] = $subcat['max_cost_prj'];
                 $nsum_min_prj = $nsum_min_prj + $subcat['min_cost_prj'];
                 $nsum_max_prj = $nsum_max_prj + $subcat['max_cost_prj'];
                 $nsum_avg_prj = $nsum_avg_prj + $subcat['avg_cost_prj'];
                 $nsum_min_hour = $nsum_min_hour + $subcat['min_cost_hour'];
                 $nsum_max_hour = $nsum_max_hour + $subcat['max_cost_hour'];
                 $nsum_avg_hour = $nsum_avg_hour + $subcat['avg_cost_hour'];
                 if ($subcat['avg_cost_prj'] != 0) {
                     $ncount_prj++;
                 }
                 if ($subcat['avg_cost_hour'] != 0) {
                     $ncount_hour++;
                 }
             }
             if ($ncount_prj == 0) {
                 $ncount_prj = 1;
             }
             if ($ncount_hour == 0) {
                 $ncount_hour = 1;
             }
             $professions_cost['prj']['min'][$cat['id']][0] = round($nsum_min_prj / $ncount_prj, 0);
             $professions_cost['prj']['avg'][$cat['id']][0] = round($nsum_avg_prj / $ncount_prj, 0);
             $professions_cost['prj']['max'][$cat['id']][0] = round($nsum_max_prj / $ncount_prj, 0);
             $professions_cost['hour']['min'][$cat['id']][0] = round($nsum_min_hour / $ncount_hour, 0);
             $professions_cost['hour']['avg'][$cat['id']][0] = round($nsum_avg_hour / $ncount_hour, 0);
             $professions_cost['hour']['max'][$cat['id']][0] = round($nsum_max_hour / $ncount_hour, 0);
         }
         switch ($prj_costby) {
             case '1':
                 $itype = 'hour';
                 $ctype = 1;
                 break;
             case '2':
                 $itype = 'hour';
                 $ctype = 8;
                 break;
             case '3':
                 $itype = 'hour';
                 $ctype = 22 * 8;
                 break;
             case '4':
                 $itype = 'prj';
                 $ctype = 1;
                 break;
         }
         $sql = "SELECT * FROM project_to_spec WHERE project_id=?i";
         $prj_cats = $DB->rows($sql, $prj_id);
         $count = 1;
         $sum_min = 0;
         $sum_avg = 0;
         $sum_max = 0;
         foreach ($prj_cats as $prj_cat) {
             $sum_min = $sum_min + $professions_cost[$itype]['min'][$prj_cat['category_id']][$prj_cat['subcategory_id']];
             $sum_avg = $sum_avg + $professions_cost[$itype]['avg'][$prj_cat['category_id']][$prj_cat['subcategory_id']];
             $sum_max = $sum_max + $professions_cost[$itype]['max'][$prj_cat['category_id']][$prj_cat['subcategory_id']];
             $sum_min = $sum_min / $count;
             $sum_avg = $sum_avg / $count;
             $sum_max = $sum_max / $count;
             $count++;
         }
         $s_min = $sum_min * $ctype;
         $s_avg = $sum_avg * $ctype;
         $s_max = $sum_max * $ctype;
         require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/project_exrates.php";
         $oprj_exrates = new project_exrates();
         $prj_exrates = $oprj_exrates->GetAll();
         switch ($prj_currency) {
             case '2':
                 $prj_cost_fm = $prj_cost * $prj_exrates['41'];
                 break;
             case '0':
                 $prj_cost_fm = $prj_cost * $prj_exrates['31'];
                 break;
             case '1':
                 $prj_cost_fm = $prj_cost * $prj_exrates['21'];
                 break;
             default:
                 $prj_cost_fm = $prj_cost * 1;
                 break;
         }
         if ($prj_cost_fm <= $s_min) {
             $prj_budget_type = 1;
         }
         if ($prj_cost_fm > $s_min && $prj_cost_fm <= $s_avg || $prj_cost_fm >= $s_avg && $prj_cost_fm < $s_max) {
             $prj_budget_type = 2;
         }
         if ($prj_cost_fm >= $s_max) {
             $prj_budget_type = 3;
         }
     }
     $projectData = self::GetProject($prj_id);
     if (is_array($projectData) && $projectData['kind'] == 7) {
         $prj_costby = 0;
     }
     $sql = "UPDATE projects \n                SET cost = ?,\n                    currency = ?i,\n                    priceby = ?i,\n                    budget_type = ?i\n                WHERE id = ?i";
     $DB->query($sql, $prj_cost, $prj_currency, $prj_costby, $prj_budget_type, $prj_id);
     return array('cost' => $prj_cost, 'currency' => $prj_currency, 'costby' => $prj_costby, 'budget_type' => $prj_budget_type);
 }
Ejemplo n.º 6
0
$proj_groups = professions::GetAllGroupsLite();
$commune = new commune();
$uid = get_uid();
if (!($communes_my = commune::GetCommunes(NULL, $uid, NULL, commune::OM_CM_MY))) {
    $communes_my = array();
}
if (!($communes = commune::GetCommunes(NULL, NULL, $uid, commune::OM_CM_JOINED, $uid))) {
    $communes = array();
}
foreach ($communes_my as $cm) {
    $communes[] = $cm;
}
$c_signed = $commune->getSubscribedCommunes($uid);
$categories = professions::GetAllGroupsLite();
$professions = professions::GetAllProfessions();
array_group($professions, 'groupid');
$professions[0] = array();
?>
<script type="text/javascript">
//    function fixCommunes(){
//        var ele = $('ch7');
//        var list = $('comm_container').getElements('input[type=checkbox]');
//        for(var i = 0; i < list.length; i++){
//            list[i].disabled = !ele.checked;
//        }
//    }
    window.addEvent('domready', function() {
//        fixCommunes();
    });
</script>
Ejemplo n.º 7
0
Archivo: arr.php Proyecto: tapiau/muyo
 /**
  * @param callable $callable
  * @param null|mixed $keyspace
  * @return callable
  */
 function array_group_dg($callable, $keyspace = null)
 {
     return function ($array) use($callable, $keyspace) {
         return array_group($array, $callable, $keyspace);
     };
 }
function quickprjedit_get_prj($prj_id)
{
    $objResponse = new xajaxResponse();
    if (hasPermissions('projects')) {
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php';
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php';
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/country.php';
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/city.php';
        $categories = professions::GetAllGroupsLite();
        $professions = professions::GetAllProfessions();
        array_group($professions, 'groupid');
        $professions[0] = array();
        $oprj = new new_projects();
        $project = $oprj->getPrj($prj_id);
        if ($project['id']) {
            $project_categories = $oprj->getSpecs($project['id']);
            if (empty($project_categories)) {
                $project_categories[] = array('category_id' => 0, 'subcategory_id' => 0);
            }
            $html_categories = '';
            foreach ($project_categories as $project_category) {
                $html_categories .= "<div id='category_line'>\n                                        <select name='categories[]' class='b-select__select b-select__select_width_180' onchange='popupQEditPrjRefreshSubCategory(this);'>\n                                            <option value='0'>Выберите раздел</option>\n                                     ";
                foreach ($categories as $cat) {
                    if ($cat['id'] <= 0) {
                        continue;
                    }
                    $html_categories .= "<option value='{$cat['id']}' " . ($project_category['category_id'] == $cat['id'] ? ' selected' : '') . ">{$cat['name']}</option>";
                }
                $html_categories .= "</select>\n                                        <select name='subcategories[]' class='b-select__select b-select__select_width_180'>\n                                    ";
                $categories_specs = $professions[$project_category['category_id']];
                for ($i = 0; $i < sizeof($categories_specs); ++$i) {
                    $html_categories .= "<option value='{$categories_specs[$i]['id']}'" . ($categories_specs[$i]['id'] == $project_category['subcategory_id'] ? ' selected' : '') . ">{$categories_specs[$i]['profname']}</option>";
                }
                $html_categories .= "      <option value='0' " . ($project_category['subcategory_id'] == 0 ? ' selected' : '') . '>Все специализации</option>
                                        </select>
                                     </div>
                                     ';
            }
            $countries = country::GetCountries();
            if ($project['country']) {
                $cities = city::GetCities($project['country']);
            }
            $html_location = '';
            $html_location .= "<div><select id='popup_qedit_prj_fld_country' name='country' onChange='popupQEditPrjCityUpd(this.value);'><option value='0'>Страна</option>";
            foreach ($countries as $country_id => $country) {
                $html_location .= "<option value='{$country_id}' " . ($country_id == $project['country'] ? 'selected' : '') . ">{$country}</option>";
            }
            $html_location .= '</select></div>';
            $html_location .= "<div id='frm_city'><select name='city'><option value='0'>Город</option>";
            if ($cities) {
                foreach ($cities as $city_id => $city) {
                    $html_location .= "<option value='{$city_id}' " . ($city_id == $project['city'] ? 'selected' : '') . ">{$city}</option>";
                }
            }
            $html_location .= '</select>';
            $objResponse->assign('popup_qedit_prj_fld_id', 'value', $project['id']);
            $objResponse->assign('popup_qedit_prj_fld_name', 'value', htmlspecialchars_decode($project['name'], ENT_QUOTES));
            $objResponse->assign('popup_qedit_prj_fld_descr', 'value', htmlspecialchars_decode($project['descr'], ENT_QUOTES));
            $objResponse->assign('popup_qedit_prj_fld_categories', 'innerHTML', $html_categories);
            $objResponse->assign('popup_qedit_prj_fld_location', 'innerHTML', $html_location);
            $objResponse->script('$("popup_qedit_prj_fld_kind_1").set("checked", false);');
            switch ($project['kind']) {
                case 1:
                    $objResponse->script('$("popup_qedit_prj_cal1").setStyle("display", "none");');
                    $objResponse->script('$("popup_qedit_prj_cal2").setStyle("display", "none");');
                    $objResponse->script('$("popup_qedit_prj_kind").setStyle("display", "block");');
                    $objResponse->script('$("popup_qedit_prj_fld_kind_1").set("checked", true);');
                    $objResponse->script('$("popup_qedit_prj_fld_location").setStyle("display", "none");');
                    break;
                case 2:
                    //$objResponse->script('$("sbr_text_block").setStyle("display", "none");');
                    break;
                case 4:
                    $objResponse->script('$("popup_qedit_prj_cal1").setStyle("display", "none");');
                    $objResponse->script('$("popup_qedit_prj_cal2").setStyle("display", "none");');
                    $objResponse->script('$("popup_qedit_prj_kind").setStyle("display", "block");');
                    $objResponse->script('$("popup_qedit_prj_fld_kind_2").set("checked", true);');
                    $objResponse->script('$("popup_qedit_prj_fld_location").setStyle("display", "block");');
                    break;
                case 7:
                    $objResponse->script('$("popup_qedit_prj_cal1").setStyle("display", "block");');
                    $objResponse->script('$("popup_qedit_prj_cal2").setStyle("display", "block");');
                    $objResponse->script('$("popup_qedit_prj_kind").setStyle("display", "none");');
                    $objResponse->script('$("popup_qedit_prj_fld_location").setStyle("display", "none");');
                    $objResponse->script('$("popup_qedit_prj_fld_end_date").set("value", "' . date('d-m-Y', strtotime($project['end_date'])) . '");');
                    $objResponse->script('$("popup_qedit_prj_fld_win_date").set("value", "' . date('d-m-Y', strtotime($project['win_date'])) . '");');
                    break;
            }
            if ($project['pro_only'] == 't') {
                $objResponse->script('$("popup_qedit_prj_fld_pro_only").set("checked", true);');
            } else {
                $objResponse->script('$("popup_qedit_prj_fld_pro_only").set("checked", false);');
            }
            if ($project['verify_only'] == 't') {
                $objResponse->script('$("popup_qedit_prj_fld_verify_only").set("checked", true);');
            } else {
                $objResponse->script('$("popup_qedit_prj_fld_verify_only").set("checked", false);');
            }
            if ($project['prefer_sbr'] == 't') {
                $objResponse->script('$("popup_qedit_prj_fld_prefer_sbr").set("checked", true);');
            } else {
                $objResponse->script('$("popup_qedit_prj_fld_prefer_sbr").set("checked", false);');
            }
            if ($project['strong_top'] == 1) {
                $objResponse->script('$("popup_qedit_prj_fld_strong_top").set("checked", true);');
            } else {
                $objResponse->script('$("popup_qedit_prj_fld_strong_top").set("checked", false);');
            }
            /*if($project['prefer_sbr']=='t') {
                  $objResponse->script('$("popup_qedit_prj_fld_prefer_sbr").set("checked", true);');
              } else {
                  $objResponse->script('$("popup_qedit_prj_fld_prefer_sbr").set("checked", false);');
              }*/
            $objResponse->script("var mx = new MultiInput('popup_qedit_prj_fld_categories','category_line', " . (int) ($project['is_pro'] === 't') . '); mx.init();');
            require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php';
            $attchedfiles = new attachedfiles($attachedfiles_session);
            $attachedfiles_tmpprj_files = $oprj->GetAllAttach($project['id']);
            if ($attachedfiles_tmpprj_files) {
                $attachedfiles_prj_files = array();
                foreach ($attachedfiles_tmpprj_files as $attachedfiles_prj_file) {
                    $attachedfiles_prj_files[] = $attachedfiles_prj_file['file_id'];
                }
                $attchedfiles->setFiles($attachedfiles_prj_files);
            }
            $attachedfiles_files = $attchedfiles->getFiles();
            $js_attachedfiles = 'attachedfiles_list = [];';
            if ($attachedfiles_files) {
                $n = 0;
                foreach ($attachedfiles_files as $attachedfiles_file) {
                    $js_attachedfiles .= "attachedfiles_list[{$n}] = new Object;\n";
                    $js_attachedfiles .= "attachedfiles_list[{$n}].id = '" . md5($attachedfiles_file['id']) . "';\n";
                    $js_attachedfiles .= "attachedfiles_list[{$n}].name = '{$attachedfiles_file['orig_name']}';\n";
                    $js_attachedfiles .= "attachedfiles_list[{$n}].path = '" . WDCPREFIX . "/{$attachedfiles_file['path']}{$attachedfiles_file['name']}';\n";
                    $js_attachedfiles .= "attachedfiles_list[{$n}].size = '" . ConvertBtoMB($attachedfiles_file['size']) . "';\n";
                    $js_attachedfiles .= "attachedfiles_list[{$n}].type = '{$attachedfiles_file['type']}';\n";
                    ++$n;
                }
            }
            $objResponse->script($js_attachedfiles);
            $objResponse->script("attachedFiles.init('popup_qedit_prj_attachedfiles', '" . $attchedfiles->getSession() . "', attachedfiles_list, " . tmp_project::MAX_FILE_COUNT . ', ' . tmp_project::MAX_FILE_SIZE . ",'" . implode(', ', $GLOBALS['disallowed_array']) . "', 'project', " . get_uid(false) . ');');
            if ($project['is_color'] == 't') {
                $objResponse->script("\$('popup_qedit_prj_is_color').set('checked', true); popupQEditPrjToggleIsColor();");
            } else {
                $objResponse->script("\$('popup_qedit_prj_is_color').set('checked', false); popupQEditPrjToggleIsColor();");
            }
            if ($project['is_bold'] == 't') {
                $objResponse->script("\$('popup_qedit_prj_is_bold').set('checked', true); popupQEditPrjToggleIsBold();");
            } else {
                $objResponse->script("\$('popup_qedit_prj_is_bold').set('checked', false); popupQEditPrjToggleIsBold();");
            }
            if ($project['hide'] == 't') {
                $objResponse->script("\$('popup_qedit_prj_is_hide').set('checked', true); ");
            } else {
                $objResponse->script("\$('popup_qedit_prj_is_hide').set('checked', false); ");
            }
            if ($project['urgent'] == 't') {
                $objResponse->script("\$('popup_qedit_prj_is_urgent').set('checked', true); ");
            } else {
                $objResponse->script("\$('popup_qedit_prj_is_urgent').set('checked', false); ");
            }
            $objResponse->assign('popup_qedit_prj_logolink', 'value', $project['link']);
            $key = md5(uniqid($uid));
            $tmpPrj = new tmp_project($key);
            $tmpPrj->init(1, $project['id']);
            $remTPeriod = $tmpPrj->getRemainingTopPeriod($remTD, $remTH, $remTM, $remtverb);
            $addedTD = $tmpPrj->getAddedTopDays();
            $objResponse->assign('popup_qedit_prj_fld_tmpid', 'value', $key);
            if ($remTPeriod || $addedTD) {
                $objResponse->script('$("popup_qedit_prj_top_ok").set("checked", true);');
                $objResponse->script('$("popup_qedit_prj_top_ok").set("disabled", true);');
                $objResponse->script('$("popup_qedit_prj_top_ok_tab1_days").set("value", "1");');
                $objResponse->script('$("popup_qedit_prj_top_ok_icon").setStyle("display", "block");');
                $objResponse->script('$("popup_qedit_prj_top_ok_tab1").setStyle("display", "none");');
                $objResponse->script('$("popup_qedit_prj_top_ok_tab2").setStyle("display", "block");');
                $objResponse->script('$("popup_qedit_prj_top_ok_tab1_days").set("disabled", true);');
                $objResponse->script('$("popup_qedit_prj_top_ok_tab2_c").set("checked", false);');
                $objResponse->script('$("popup_qedit_prj_top_ok_tab2_c").set("disabled", false);');
                $objResponse->script('$("popup_qedit_prj_top_ok_tab2_days").set("disabled", false);');
                $objResponse->script('$("popup_qedit_prj_top_ok_tab2_days").set("value", "1");');
                $objResponse->script('$("popup_qedit_prj_top_ok_tab2_left").set("html", "' . $remtverb . ' ' . $remTPeriod . '");');
            } else {
                $objResponse->script('$("popup_qedit_prj_top_ok").set("checked", false);');
                $objResponse->script('$("popup_qedit_prj_top_ok").set("disabled", false);');
                $objResponse->script('$("popup_qedit_prj_top_ok_tab1_days").set("value", "1");');
                $objResponse->script('$("popup_qedit_prj_top_ok_icon").setStyle("display", "none");');
                $objResponse->script('$("popup_qedit_prj_top_ok_tab1").setStyle("display", "none");');
                $objResponse->script('$("popup_qedit_prj_top_ok_tab2").setStyle("display", "none");');
                $objResponse->script('$("popup_qedit_prj_top_ok_tab1_days").set("disabled", false);');
                $objResponse->script('$("popup_qedit_prj_top_ok_tab2_c").set("checked", false);');
                $objResponse->script('$("popup_qedit_prj_top_ok_tab2_c").set("disabled", true);');
                $objResponse->script('$("popup_qedit_prj_top_ok_tab2_days").set("disabled", true);');
            }
            if ($project['logo_id']) {
                $logo = $tmpPrj->getLogo();
                $objResponse->script('$("popup_qedit_prj_use_logo_src").set("href", "' . WDCPREFIX . '/' . $logo['path'] . $logo['name'] . '");');
                $objResponse->script('$("popup_qedit_prj_use_logo").set("checked", true);');
                $objResponse->script('$("popup_qedit_prj_use_logo").set("disabled", true);');
                $objResponse->script('$("popup_qedit_prj_use_logo_tab").setStyle("display", "block");');
                $objResponse->script('$("popup_qedit_prj_use_logo_tab2").setStyle("display", "none");');
            } else {
                $objResponse->script('$("popup_qedit_prj_use_logo").set("checked", false);');
                $objResponse->script('$("popup_qedit_prj_use_logo").set("disabled", false);');
                $objResponse->script('$("popup_qedit_prj_use_logo_tab").setStyle("display", "none");');
                $objResponse->script('$("popup_qedit_prj_use_logo_tab2").setStyle("display", "none");');
            }
            $tmpPrj->fix();
            $objResponse->call('center_popup', '.b-shadow_center-quick');
        }
    }
    return $objResponse;
}
Ejemplo n.º 9
0
 /**
  * Генерирует попап для выбора раздела в RSS.
  */
 public function ShowRSSPopup($kind)
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php';
     switch ($kind) {
         case 0:
         case 1:
             $rss_link = 'projects.xml';
             break;
         case 2:
             $rss_link = 'competition.xml';
             break;
         case 4:
             $rss_link = 'office.xml';
             break;
         case 6:
             $rss_link = 'pro.xml';
             break;
         case 5:
             $rss_link = 'all.xml';
             break;
         default:
             $rss_link = 'all.xml';
             break;
     }
     $categories = professions::GetAllGroupsLite();
     //        $subcat = professions::GetAllProfessions();
     //        var_dump(professions::GetAllProfessions());
     $script = "\n            <script type='text/javascript'>\n            var sub = new Array();\n        ";
     $professions = professions::GetAllProfessions();
     array_group($professions, 'groupid');
     $professions[0] = array();
     foreach ($categories as $cat) {
         $out_s = array();
         $script .= "\n                sub[{$cat['id']}] = new Array(\n            ";
         if (is_array($professions[$cat['id']])) {
             foreach ($professions[$cat['id']] as $subcat) {
                 $out_s[] = " new Array({$subcat['id']}, '" . clearTextForJS($subcat['profname']) . "') ";
             }
             $script .= implode(', ', $out_s);
         }
         $script .= '
             );
         ';
     }
     $script .= "\n            function applySubcat(cat){\n                if(typeof sub[cat] != 'undefined')\n                for(var i = 0; i < sub[cat].length; i++){\n                    var option = document.createElement('option');\n                    option.value = sub[cat][i][0];\n                    option.innerHTML = sub[cat][i][1];\n                    document.getElementById('rss_sub').appendChild(option);\n                }\n            }\n\n            function getRssUri(){\n                var cat = document.getElementById('rss_cat').value;\n                var sub = document.getElementById('rss_sub').value;\n                var xml_path = '/rss/{$rss_link}';\n                if(sub){\n                    return xml_path+'?subcategory='+sub+(cat ? '&category='+cat : '');\n                }else if(cat){\n                    return xml_path+'?category='+cat;\n                }else{\n                    return xml_path;\n                }\n            }\n\n            function gotoRSS(){\n                document.location.href = getRssUri();\n            }\n\n            function clearSelect(sid)\n            {\n\n            var oListbox = document.getElementById(sid);\n            for (var i=oListbox.options.length-1; i >= 0; i--)\n            {\n                oListbox.remove(i);\n            }\n\n            }\n\n            function showRSS(){\n                clearSelect('rss_sub');\n                // var newoption = new Option('Весь раздел', '');\n                var newoption = document.createElement('option');\n                newoption.value = '';\n                newoption.innerHTML = 'Весь раздел';\n                document.getElementById('rss_sub').appendChild(newoption);\n                document.getElementById('rss_cat').value = '';\n                document.getElementById('rsso').style.display='block';\n            }\n\n\n            function FilterSubCategoryRSS(category)\n            {\n                var objSel = \$('rss_sub');\n                objSel.options.length = 0;\n                objSel.disabled = 'disabled';\n                objSel.options[objSel.options.length] = new Option('Весь раздел', 0);\n                if(category == 0) {\n                    objSel.set('disabled', true);\n                } else {\n                    objSel.set('disabled', false);\n                }\n                //  var ft = true;\n                applySubcat(category);\n                //  for (i in filter_specs[category]) {\n                //  if (filter_specs[category][i][0]) {\n                //  objSel.options[objSel.options.length] = new Option(filter_specs[category][i][1], filter_specs[category][i][0], ft, ft);\n                //  ft = false;\n                //  }\n                //  }\n                objSel.value = 0;\n            }\n            </script>\n        ";
     // $subcategories = professions::Get
     $select = '<select style="width:340px"  onchange="FilterSubCategoryRSS(this.value);" name="rss_cat" id="rss_cat">><option value="">Все разделы</option>';
     foreach ($categories as $cat) {
         if (!$cat['id']) {
             continue;
         }
         $select .= "<option value=\"{$cat['id']}\">{$cat['name']}</option>";
     }
     $select .= '</select>';
     return "\n        {$script}\n        <div style=\"display: none;\" class=\"overlay ov-out\" id=\"rsso\">\n            <b class=\"c1\"></b>\n            <b class=\"c2\"></b>\n            <b class=\"ov-t\"></b>\n            <div class=\"ov-r\">\n               <div class=\"ov-l\">\n                       <div class=\"ov-in\" style=\"height:110px\">\n                            <label for=\"rss\">Укажите разделы:</label>&nbsp;&nbsp;<br/>{$select}<br/>\n                            <label for=\"rss_sub\">Укажите подразделы:</label>&nbsp;&nbsp;<br/><select style=\"width:340px\" name=\"rss_sub\" id=\"rss_sub\">\n                            <option value=\"\">Весь раздел</option>\n                            </select>\n                            <div class=\"ov-btns\">\n                                <input value=\"Подписаться\" class=\"i-btn i-bold\" type=\"button\" onClick=\"gotoRSS(); document.getElementById('rsso').style.display='none'; return false;\">\n                                <input value=\"Отменить\" class=\"i-btn\" onclick=\"\$(this).getParent('div.overlay').setStyle('display', 'none'); return false;\" type=\"button\">\n                           </div>\n                       </div>\n                    </div>\n                 </div>\n              <b class=\"ov-b\"></b>\n              <b class=\"c3\"></b>\n               <b class=\"c4\"></b>\n           </div>";
 }
Ejemplo n.º 10
0
 /**
  * Обработка информации шага проекты.
  */
 public function actionProjects()
 {
     $prj_id = $_SESSION['view_wizard_project'];
     if (!$prj_id) {
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php';
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/project_exrates.php';
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php';
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php';
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/country.php';
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/city.php';
         $prj_exrates = project_exrates::GetAll();
         $categories = professions::GetAllGroupsLite();
         $professions = professions::GetAllProfessions();
         array_group($professions, 'groupid');
         $professions[0] = array();
         $addedPrc = is_pro() ? 0 : new_projects::PRICE_ADDED;
         $colorPrc = new_projects::PRICE_COLOR * ($addedPrc > 0 ? 1 : 0);
         $boldPrc = new_projects::PRICE_BOLD + $addedPrc;
         $logoPrc = new_projects::PRICE_LOGO + $addedPrc;
         $cTopPrice = new_projects::PRICE_CONTEST_TOP1DAY + $addedPrc;
         $pTopPrice = new_projects::PRICE_TOP1DAY + $addedPrc;
         $action = __paramInit('string', 'action', 'action', null);
         $attachedfiles_session = __paramInit('string', 'attachedfiles_session', 'attachedfiles_session', false);
         // проверяем есть ли уже созданый проект
         $projects = $this->getCreatedProjects();
         $existPrjID = count($projects) > 0 ? $projects[0][id] : null;
         // выводим ранее сохраненный проект
         if ($action != 'create_project' && $existPrjID) {
             $data = $projects[0];
             list($category, $subcategory) = explode('|', $data['categories']);
             $currency_name = $this->CURRENCY_TYPE[$data['currency']];
             $priceby_name = $this->PRICEBY_TYPE[$data['priceby']];
             $data['pro_only'] = $data['pro_only'] === 't';
             $price = $data['payed'];
             $option = array();
             $option['top'] = $data['top_count'] > 0;
             $option['top_count'] = $data['top_count'];
             $option['color'] = $data['is_color'] === 't';
             $option['bold'] = $data['is_bold'] === 't';
             $option['logo'] = $data['logo_id'] > 0;
         } elseif ($action == 'create_project') {
             // сохраняем новый проект или изменяем старый
             $in_office = __paramInit('int', null, 'in_office', 0);
             $type = __paramInit('string', null, 'kind');
             if ($type == 'contest') {
                 $data['kind'] = 7;
                 $data['end_date'] = date('d-m-Y', strtotime(__paramInit('string', null, 'end_date_eng_format', 0)));
                 $data['win_date'] = date('d-m-Y', strtotime(__paramInit('string', null, 'win_date_eng_format', 0)));
             } elseif ($in_office == 1) {
                 $location = __paramInit('integer', null, 'location_column_id');
                 if ($location == 1) {
                     $data['city'] = __paramInit('integer', null, 'location_db_id');
                     $data['country'] = country::getCountryByCityId($data['city']);
                 } else {
                     $data['country'] = __paramInit('integer', null, 'location_db_id');
                 }
                 $data['kind'] = 4;
             } else {
                 $data['kind'] = 1;
             }
             $data['name'] = __paramInit('string', null, 'name');
             $data['descr'] = __paramInit('string', null, 'descr');
             $category = __paramInit('int', null, 'r_category');
             $subcategory = __paramInit('int', null, 'r_subcategory');
             $agreement = __paramInit('int', null, 'agreement', 0);
             $data['pro_only'] = __paramInit('int', null, 'pro_only', 0) == 1 ? true : false;
             if ($agreement != 1) {
                 $data['cost'] = __paramInit('int', null, 'cost', 0);
                 $data['priceby'] = __paramInit('int', null, 'r_priceby', 0);
                 $data['currency'] = __paramInit('int', null, 'r_currency', 0);
                 $data['budget_type'] = __paramInit('int', null, 'budget_type', 0);
             }
             if (is_empty_html($data['descr'])) {
                 $error['descr'] = 'Поле не заполнено';
             }
             if (is_empty_html($data['name'])) {
                 $error['name'] = 'Поле не заполнено';
             }
             // проверяем длину необработанной строки, а иначе спецсимволы считаются как несколько символов
             if (strlen(stripslashes($_POST['name'])) > 60) {
                 $error['name'] = 'Превышен лимит - 60 символов';
             }
             if (!$category) {
                 $error['category'] = 'Не выбран раздел';
             } elseif ($subcategory) {
                 $data['categories'] = "{$category}|{$subcategory}";
             } else {
                 $data['categories'] = $category;
             }
             if ($data['cost'] < 0) {
                 $error['cost'] = 'Введите положительную сумму';
             }
             if ($data['cost'] > 999999) {
                 $error['cost'] = 'Слишком большая сумма';
             }
             if ($data['cost'] > 0 && ($data['currency'] < 0 || $data['currency'] > 3)) {
                 $error['currency'] = 'Валюта не определена';
             }
             if ($data['cost'] > 0 && ($data['priceby'] < 1 || $data['priceby'] > 4)) {
                 $error['priceby'] = 'Вид бюджета не определен';
             }
             $descr_limit = projects::LIMIT_DESCR;
             if (strlen_real($data['descr']) > $descr_limit) {
                 $error['descr'] = "Исчерпан лимит символов ({$descr_limit})";
             }
             if ($data['kind'] == 7) {
                 if (!preg_match("/^([0-9]{1,2})\\-([0-9]{1,2})\\-([0-9]{4})\$/", $data['end_date'], $o1) || !checkdate($o1[2], $o1[1], $o1[3])) {
                     $error['end_date'] = 'Неправильная дата';
                 }
                 if (!preg_match("/^([0-9]{1,2})\\-([0-9]{1,2})\\-([0-9]{4})\$/", $data['win_date'], $o2) || !checkdate($o2[2], $o2[1], $o2[3])) {
                     $error['win_date'] = 'Неправильная дата';
                 }
                 if (!$error['end_date'] && mktime(0, 0, 0, $o1[2], $o1[1], $o1[3]) <= mktime(0, 0, 0)) {
                     $error['end_date'] = 'Дата окончания конкурса не может находиться  в прошлом';
                 }
                 if (!$error['win_date'] && mktime(0, 0, 0, $o2[2], $o2[1], $o2[3]) <= mktime(0, 0, 0, $o1[2], $o1[1], $o1[3])) {
                     $error['win_date'] = 'Дата определения победителя должна быть больше даты окончания конкурса';
                 }
             }
             $option['top'] = __paramInit('int', null, 'option_top', 0);
             $option['top_count'] = __paramInit('int', null, 'option_top_count', 0);
             $option['color'] = __paramInit('int', null, 'option_color', 0);
             $option['bold'] = __paramInit('int', null, 'option_bold', 0);
             $option['logo'] = __paramInit('int', null, 'option_logo', 0);
             // логотип
             if ($option['logo'] == 1) {
                 $data['logo_link'] = str_replace('http://', '', __paramInit('string', null, 'logo_link', null));
                 $data['logo_id'] = __paramInit('int', null, 'logo_id', null);
                 // если выбрана опция "Логотип со ссылкой", то картинка должна быть обязательно
                 if (!$data['logo_id']) {
                     $error['logo_image'] = 'Отсутствует логотип';
                 }
                 if ($data['logo_link'] === 'Адрес сайта') {
                     $data['logo_link'] = '';
                 }
                 if ($data['logo_link'] !== '' && !is_url($data['logo_link'])) {
                     $error['logo_link'] = 'Не верно введен адрес';
                 }
             } else {
                 $data['logo_id'] = null;
             }
             $price = 0;
             // закрепление на верху
             if ($option['top'] == 1 && $option['top_count'] > 0) {
                 if ($option['top_count'] > 999) {
                     $option['top_count'] = 999;
                 }
                 $price = (int) $option['top_count'] * ($data['kind'] == 7 ? $cTopPrice : $pTopPrice);
                 $data['top_count'] = (int) $option['top_count'];
                 $pay_option[] = array('wiz_uid' => $this->getWizardUserID(), 'op_code' => new_projects::OPCODE_PAYED, 'option' => self::PROJECT_OPTION_TOP, 'type' => $data['kind'] == 7 ? self::BILL_TYPE_CONTEST : self::BILL_TYPE_PROJECT, 'ammount' => $price);
             } else {
                 $data['top_count'] = 0;
             }
             // выделение цветом
             if ($option['color'] == 1) {
                 $price += (int) $colorPrc;
                 $data['is_color'] = true;
                 $pay_option[] = array('wiz_uid' => $this->getWizardUserID(), 'op_code' => new_projects::OPCODE_PAYED, 'option' => self::PROJECT_OPTION_COLOR, 'type' => $data['kind'] == 7 ? self::BILL_TYPE_CONTEST : self::BILL_TYPE_PROJECT, 'ammount' => $colorPrc);
             } else {
                 $data['is_color'] = false;
             }
             // выделение жирным
             if ($option['bold'] == 1) {
                 $price += (int) $boldPrc;
                 $data['is_bold'] = true;
                 $pay_option[] = array('wiz_uid' => $this->getWizardUserID(), 'op_code' => new_projects::OPCODE_PAYED, 'option' => self::PROJECT_OPTION_BOLD, 'type' => $data['kind'] == 7 ? self::BILL_TYPE_CONTEST : self::BILL_TYPE_PROJECT, 'ammount' => $boldPrc);
             } else {
                 $data['is_bold'] = false;
             }
             if ($option['logo'] == 1) {
                 $price += (int) $logoPrc;
                 $pay_option[] = array('wiz_uid' => $this->getWizardUserID(), 'op_code' => new_projects::OPCODE_PAYED, 'option' => self::PROJECT_OPTION_LOGO, 'type' => $data['kind'] == 7 ? self::BILL_TYPE_CONTEST : self::BILL_TYPE_PROJECT, 'ammount' => $logoPrc);
             }
             if ($price > 0) {
                 $data['payed'] = (int) $price;
             }
             if (!$error) {
                 $data['wiz_uid'] = $this->getWizardUserID();
                 // если проект уже есть
                 if ($existPrjID) {
                     // то просто обновляем его
                     $prj_id = $this->updateProject($data, $existPrjID);
                     // и очищаем все платные опции для этого проекта
                     wizard_billing::clearPayedOptions($prj_id);
                 } else {
                     $prj_id = $this->createProject($data);
                 }
                 if ($prj_id && $_POST['attachedfiles_session']) {
                     $attachedfiles = new attachedfiles($_POST['attachedfiles_session']);
                     $files = $attachedfiles->getFiles(array(1, 2, 3, 4));
                     $this->parent->addAttachedFiles($files, $prj_id);
                     $attachedfiles->clear();
                 }
                 if ($prj_id && $data['kind'] == 7) {
                     $insert = array('wiz_uid' => $data['wiz_uid'], 'op_code' => new_projects::OPCODE_KON_NOPRO, 'type' => self::BILL_TYPE_CONTEST, 'ammount' => new_projects::getKonkursPrice(), 'parent' => $prj_id);
                     wizard_billing::addPaidOption($insert);
                 }
                 if ($price > 0 && $prj_id) {
                     foreach ($pay_option as $k => $opt) {
                         $opt['parent'] = $prj_id;
                         wizard_billing::addPaidOption($opt);
                     }
                 }
                 if ($prj_id) {
                     $_SESSION['view_wizard_project'] = $prj_id;
                     header('Location: /wizard/registration/');
                     exit;
                 } else {
                     $error['project'] = 'Ошибка записи проекта';
                 }
             }
             $currency_name = __paramInit('string', null, 'currency');
             $priceby_name = __paramInit('string', null, 'priceby');
         }
         // Генерируем данные для вывода ошибок и заполнения полей
         $loc[] = country::GetCountryName($data['country']);
         if ($data['city']) {
             $loc[] = city::GetCityName($data['city']);
         }
         $location_name = implode(': ', $loc);
         $cat[] = professions::GetGroupName($category);
         if ($subcategory) {
             $cat[] = professions::GetProfName($subcategory);
         }
         $category_name = implode(': ', $cat);
         if ($data['logo_id']) {
             $file = new CFile($data['logo_id']);
             $logo_path = WDCPREFIX . '/' . $file->path . $file->name;
         }
         include $_SERVER['DOCUMENT_ROOT'] . '/wizard/registration/steps/tpl.step.project.php';
     } else {
         $project = $this->getProjectById($prj_id);
         $attached = $this->getProjectAttach($prj_id);
         include $_SERVER['DOCUMENT_ROOT'] . '/wizard/registration/steps/tpl.step.project.view.php';
     }
 }