Example #1
0
 /**
  * Создание категории
  */
 public function edit($id)
 {
     if (!User::isAdmin()) {
         App::abort('403');
     }
     if (!($category = Category::find_by_id($id))) {
         App::abort('default', 'Категория не найдена!');
     }
     if (Request::isMethod('post')) {
         $category->token = Request::input('token', true);
         $category->parent_id = Request::input('parent_id');
         $category->name = Request::input('name');
         $category->slug = Request::input('slug');
         $category->description = Request::input('description');
         $category->sort = Request::input('sort');
         if ($category->save()) {
             App::setFlash('success', 'Категория успешно изменена!');
             App::redirect('/category');
         } else {
             App::setFlash('danger', $category->getErrors());
             App::setInput($_POST);
         }
     }
     $categories = Category::getAll();
     App::view('categories.edit', compact('category', 'categories'));
 }
 public function make()
 {
     $values = array(Zurmo::t('CustomField', 'Labor'), Zurmo::t('CustomField', 'Equipment'), Zurmo::t('CustomField', 'Material'), Zurmo::t('CustomField', 'Subcontractor'), Zurmo::t('CustomField', 'Other'), Zurmo::t('CustomField', 'Assembly'));
     static::makeCustomFieldDataByValuesAndDefault('CostOfGoodsTypes', $values);
     $values = array(Zurmo::t('CustomField', 'All'), Zurmo::t('CustomField', 'Labor'), Zurmo::t('CustomField', 'Equipment'), Zurmo::t('CustomField', 'Material'), Zurmo::t('CustomField', 'Subcontractor'), Zurmo::t('CustomField', 'Other'));
     static::makeCustomFieldDataByValuesAndDefault('CostOfGoodsTypesAssembly', $values, $values[0]);
     $unitofMeasuresDropdownOptions = array();
     foreach (Unitofmeasure::getAll('name') as $uom) {
         $unitofMeasuresDropdownOptions[] = Zurmo::t('CustomField', $uom->name);
     }
     static::makeCustomFieldDataByValuesAndDefault('UnitOfMeasureTypes', $unitofMeasuresDropdownOptions);
     $categoriesDropdownOptions = array();
     foreach (Category::getAll('name') as $categroy) {
         $categoriesDropdownOptions[] = Zurmo::t('CustomField', $categroy->name);
     }
     static::makeCustomFieldDataByValuesAndDefault('CategoryTypes', $categoriesDropdownOptions);
     $assemblyDetailvalues = Costbook::getAllAssemblyDetails();
     $assemblyDetailDropdownOptions = array();
     foreach ($assemblyDetailvalues as $assemblyDetail) {
         if ($assemblyDetail['assemblydetail'] != NULL) {
             $tmpAssemblyoptions = explode(";", $assemblyDetail['assemblydetail']);
             foreach ($tmpAssemblyoptions as $assemblyOption) {
                 $assemblyDetailDropdownOptions[] = Zurmo::t('CustomField', $assemblyOption);
             }
         }
     }
     static::makeCustomFieldDataByValuesAndDefault('AssemblyDetailSearchTypes', $assemblyDetailDropdownOptions);
 }
Example #3
0
 static function find($searchId)
 {
     $categories_returned = Category::getAll();
     foreach ($categories_returned as $category) {
         if ($searchId == $category->getId()) {
             return $category;
         }
     }
 }
Example #4
0
 /**
  * 添加、修改文章
  */
 public function actionModify($id)
 {
     $id = (int) $id;
     $where = array('a.aid' => $id);
     $Articles = new Articles();
     $Category = new Category();
     $this->data = $Articles->select('c.*,a.*')->from('articles a')->join('articles_content c', 'a.aid=c.aid')->where($where)->getOne();
     $this->data['content'] = stripslashes($this->data['content']);
     $this->category = $Category->getAll();
 }
Example #5
0
 function test_deleteAll()
 {
     $name = "Wash the dog";
     $name2 = "Home stuff";
     $test_Category = new Category($name);
     $test_Category->save();
     $test_Category2 = new Category($name2);
     $test_Category2->save();
     Category::deleteAll();
     $result = Category::getAll();
     $this->assertEquals([], $result);
 }
Example #6
0
 static function find($search_id)
 {
     $found_category = null;
     $categories = Category::getAll();
     foreach ($categories as $category) {
         $category_id = $category->getId();
         if ($category_id == $search_id) {
             $found_category = $category;
         }
     }
     return $found_category;
 }
Example #7
0
function renderCategories($startingId, $parentId = null)
{
    $categories = Category::getAll($startingId ? array('id' => $startingId) : array('parent_id' => $parentId));
    if (!empty($categories)) {
        echo '<ul>';
        foreach ($categories as $category) {
            echo '<li><a href="/?c=' . $category->id . '">' . $category->name . '</a></li>';
            renderCategories(null, $category->id);
        }
        echo '</ul>';
    }
}
Example #8
0
 function test_getAll()
 {
     //Arrange
     $name = "Work stuff";
     $name2 = "Home stuff";
     $test_category = new Category($name);
     $test_category->save();
     $test_category2 = new Category($name2);
     $test_category2->save();
     //Act
     $result = Category::getAll();
     //Assert
     $this->assertEquals([$test_category, $test_category2], $result);
 }
Example #9
0
 static function find($search_id)
 {
     //Set a null variable for found category before functions process.
     $found_category = null;
     //Use getAll function to query and store data for php to process
     $categories = Category::getAll();
     //go through categories and extract the one with the id we are searching for.
     foreach ($categories as $category) {
         $category_id = $category->getId();
         if ($category_id == $search_id) {
             $found_category = $category;
         }
     }
     return $found_category;
 }
Example #10
0
 /**
  * Создание новости
  */
 public function create()
 {
     if (!User::isAdmin()) {
         App::abort('403');
     }
     if (Request::isMethod('post')) {
         $news = new News();
         $news->category_id = Request::input('category_id');
         $news->user_id = User::get('id');
         $news->title = Request::input('title');
         $news->slug = '';
         $news->text = Request::input('text');
         $image = Request::file('image');
         if ($image && $image->isValid()) {
             $ext = $image->getClientOriginalExtension();
             $filename = uniqid(mt_rand()) . '.' . $ext;
             if (in_array($ext, ['jpeg', 'jpg', 'png', 'gif'])) {
                 $img = new SimpleImage($image->getPathName());
                 $img->best_fit(1280, 1280)->save('uploads/news/images/' . $filename);
                 $img->best_fit(200, 200)->save('uploads/news/thumbs/' . $filename);
             }
             $news->image = $filename;
         }
         if ($news->save()) {
             if ($tags = Request::input('tags')) {
                 $tags = array_map('trim', explode(',', $tags));
                 foreach ($tags as $tag) {
                     $tag = Tag::create(['name' => $tag]);
                     $tag->create_news_tags(['news_id' => $news->id]);
                 }
             }
             App::setFlash('success', 'Новость успешно создана!');
             App::redirect('/' . $news->category->slug . '/' . $news->slug);
         } else {
             App::setFlash('danger', $news->getErrors());
             App::setInput($_POST);
         }
     }
     $categories = Category::getAll();
     App::view('news.create', compact('categories'));
 }
Example #11
0
 function getSelect()
 {
     $results = Category::getAll("title");
     foreach ($results as $row) {
         $temp[] = array("value" => $row['id'], "label" => stripslashes($row['title']));
     }
     return $temp;
 }
Example #12
0
 public function printBoardContent($user, $con)
 {
     global $permission;
     $printContent = "<div class='board'><div class=\"forum_menu\">";
     if ($user->hasPermission($permission["board_edit"], $this)) {
         $printContent .= "<a href=\"javascript:void(0)\" data-forum-target='{$this->getID()}' class='board_edit btn_small btn_white btn_flat'>Edit</a> ";
         $moderators .= "<span class='hidden_field'>Moderators: <input type='text' id='moderators_{$this->getID()}' value='{$this->getModeratorsAsString($con)}'></span>";
     }
     if ($user->hasPermission($permission["thread_create"], $this)) {
         $printContent .= "<a href=\"javascript:void(0)\" onclick = \"lightBox('newThread')\" class=\"btn_small btn_white btn_flat\">+ Thread </a> ";
     }
     if ($user->hasPermission($permission["board_create"], $this)) {
         $printContent .= "<a href=\"javascript:void(0)\" data-forum-target='{$this->getID()}' class=\"new_board_button btn_small btn_white btn_flat\">+ Board</a> ";
     }
     if ($user->hasPermission($permission["board_delete"], $this)) {
         $printContent .= "<a href=\"javascript: if(confirm('Delete Board and ALL content within?')) {window.location='{$_SERVER['PHP_SELF']}?d=b{$this->getID()}'}\" class=\"btn_small btn_white btn_flat\">Delete</a>";
     }
     if ($user->hasPermission($permission["board_move"], $this->getParent())) {
         $move = "<span class='hidden_field'>Move:<select id='move_{$this->getID()}'>";
         $move .= "<option value='-1'>--</option>";
         $categories = Category::getAll($con);
         foreach ($categories as $category) {
             if ($category != null) {
                 $move .= "<option value='c{$category->getID()}'>{$category->name}</option>";
                 foreach ($category->getChildren() as $board) {
                     $move .= "<option value='b{$board->getID()}'> - {$board->name}</option>";
                     foreach ($board->getAllSubBoards($con) as $subBoard) {
                         $indent = " -";
                         foreach ($subBoard->getAllParents($con) as $parent) {
                             $indent .= " -";
                         }
                         $move .= "<option value='b{$subBoard->getID()}'>{$indent} {$subBoard->name}</option>";
                     }
                 }
             }
         }
         $move .= "</select></span>";
     }
     $printContent .= "\r\n\t\t</div>\r\n\t\t<h2 class='editable_title header_title' id='board_title_{$this->getID()}'>{$this->name}</h2>\r\n\t\t<div class='editable_title' id='board_description_{$this->getID()}'>{$this->fields["Description"]}</div>\r\n\t\t{$moderators} {$move}\r\n\t\t<div class='clear'></div>\r\n\t\t<div class='elements_container'>" . $this->getTreeAsString();
     if ($user->hasPermission($permission["board_create"], $this)) {
         $printContent .= $this->printNewBoardForm();
     }
     if (count($this->getChildren()) > 0) {
         foreach ($this->getChildren() as $child) {
             if ($child instanceof Board) {
                 $printContent .= $child->printBoard($user);
             }
         }
         $printContent .= "<div class='clear'></div></div><div class='elements_container'>";
         foreach ($this->getChildren() as $child) {
             if ($child instanceof Thread) {
                 $printContent .= $child->printThread($user);
             }
         }
     } else {
         $printContent .= "<div class='forum_element'>No threads and boards avaliable.</div>";
     }
     $printContent .= $this->getTreeAsString() . "<div class='clear'></div></div></div>";
     return $printContent;
 }
Example #13
0
 function testDeleteAll()
 {
     //Arrange
     $name = "Wash the dog";
     $id = 1;
     $test_category = new Category($name, $id);
     $test_category->save();
     $name2 = "Water the lawn";
     $id2 = 2;
     $test_category2 = new Category($name2, $id2);
     $test_category2->save();
     //Act
     Category::deleteAll();
     //Assert
     $result = Category::getAll();
     $this->assertEquals([], $result);
 }
Example #14
0
// and a function that gives our route access to the app variable. the method then
// creates a new task object based on the data it receives from the form, and then
// saves (or pushes) the new object onto the $_SESSION array. then the method returns
// the app object (using twig) to call the render method (which receives a file path that
// contains the twig template and an array that contains the new task object, which is
// added to the list)
$app->post("/tasks", function () use($app) {
    $task = new Task($_POST['description']);
    $task->save();
    // return $app['twig']->render('create_task.html.twig', array('newtask' => $task));
    return $app['twig']->render('tasks.html.twig', array('tasks' => Task::getAll()));
});
// calls the post method on the $app object and receives a URL path as its first argument,
// and a function that gives our route access to the app variable. the method then calls
// the Task class method deleteAll(), which resets the $_SESSION array to a blank array.
// then the method returns the app object (using twig) and calls the render method (which
// receives a file path that contains the twig template)
$app->post("/delete_tasks", function () use($app) {
    Task::deleteAll();
    return $app['twig']->render('index.html.twig');
});
$app->post("/categories", function () use($app) {
    $category = new Category($_POST["name"]);
    $category->save();
    return $app["twig"]->render("categories.html.twig", array("categories" => Category::getAll()));
});
$app->post("/delete_categories", function () use($app) {
    Category::deleteAll();
    return $app["twig"]->render("index.html.twig");
});
return $app;
Example #15
0
     <div class="content_item">
        <h2>Postavljanje nove vesti</h2>
        <form class="form" method="post" action="publishnews.php" id="newsForm">
          <label>Naslov:</label><br><input type="text" name="tb_title"><br>
          <label>Podnaslov:</label><br><textarea rows="5" cols="90" name="ta_sub_title" form="newsForm"></textarea><br><br>
          <label>Kategorija : </label><select name="sel_category">
          								<?php 
$newsCat = Category::getAll();
foreach ($newsCat as $value) {
    echo "<option value='{$value->category_id}'>" . $value->name . "</option>";
}
?>
      								</select><br><br>	
          <label>Tekst vesti:</label><br><textarea rows="20" cols="90" name="ta_news" form="newsForm"></textarea><br>	
          <input id="btn" type="submit" value="Postavi vest" name="btn_submit">
        </form>

      </div><!--close content_item-->
        <br style="clear:both"/> 
      </div><!--close content-->    
 public function renderContent()
 {
     $categories = Category::getAll();
     $data = Costbook::getById($_GET['id']);
     $vAssemblyDetails = '';
     $assembly_count = 0;
     if ($data->assemblydetail != '' && $data->assemblydetailsearch == '(None)') {
         $vAssemblyDetails = explode(';', $data->assemblydetail);
     } else {
         if ($data->assemblydetail == '' && $data->assemblydetailsearch != '(None)') {
             $vAssemblyDetails = explode(', ', $data->assemblydetailsearch);
         } else {
             if ($data->assemblydetail != '' && $data->assemblydetailsearch != '(None)') {
                 $assembly_details = explode(';', $data->assemblydetail);
                 $vAssemblySearchDetails = explode(', ', $data->assemblydetailsearch);
                 $vAssemblyDetails = array_unique(array_merge($assembly_details, $vAssemblySearchDetails));
             }
         }
     }
     $assembly_count = count($vAssemblyDetails);
     $url = Yii::app()->createUrl("costbook/default/getDataAssemblySearch");
     $content = '<div class="SecuredEditAndDetailsView EditAndDetailsView DetailsView ModelView ConfigurableMetadataView MetadataView" id="CostbookEditAndDetailsView">
                         <div class="wrapper">
                             <h1>
                                 <span class="truncated-title" threedots="Create Costbook"><span class="ellipsis-content">Step 2 of 3 - Assembly Detail</span></span>
                             </h1>
                             <div class="wide form">
                             <form method="post" action="/app/index.php/costbook/default/create?clearCache=1&amp;resolveCustomData=1" id="edit-form" onsubmit="js:return $(this).attachLoadingOnSubmit(&quot;edit-form&quot;)">
                                 <input type="hidden" id="hidModelId" name="hidModelId" value="' . $_GET['id'] . '" />
                                 <input type="hidden" name="hidUOM" id="hidUOM" value="' . $data->unitofmeasure . '" />
                                     <div class="attributesContainer">
                                         <div class="left-column" style="width:100%;">
                                             <div class="border_top_In_Assembly_Detail_Level">
                                                 <div class="costBookAssemblyStep2Header" >Detail Products</div>
                                                     <table width=100% class="items" id="detail_products">
                                                         <th width=15%>Product Code</th><th width=30%>Product Name</th><th width=15%>Ratio</th><th width=20%>Base Unit of Measure</th><th width=20%>Unit of Measure</th>';
     if ($vAssemblyDetails != '') {
         for ($i = 0; $i < $assembly_count; $i++) {
             $str = explode('|', $vAssemblyDetails[$i]);
             $dataProductCode = Costbook::getByProductCode($str[1]);
             $content .= '<tr>
                                                             <td >' . $str[1] . '<input type="hidden" id="hidProductCode' . $i . '" value="' . $str[1] . '" /></td>
                                                             <td >' . $dataProductCode[0]->productname . '</td>
                                                             <td ><input type="text" id="detail_ratio' . $i . '" name="detailRatio" value="' . $str[2] . '" style="width:120px;" /></td>
                                                             <td >' . $dataProductCode[0]->unitofmeasure . '</td>
                                                             <td >per ' . $data->unitofmeasure . '<input type="hidden" name="currAssemblyCnt" id="currAssemblyCnt" value="' . $assembly_count . '" /></td>
                                                         </tr>';
         }
     }
     $content .= '</table><br>
                                                 </div>
                                                 <div class="panel border_top_In_Assembly_Detail_Level">
                                                     <div class="costBookAssemblyStep2Header">Search</div>
                                                         <table class="form-fields items" id="costBookAssemblyStep2Headerid">
                                                             <colgroup><col class="col-0"><col class="col-1"></colgroup>
                                                             <tbody>
                                                                 <tr>
                                                                     <th><label for="Costbook_assemblycategory_value">Select Category</label></th>
                                                                     <td colspan="1">
                                                                         <div class="hasDropDown">
                                                                             <span class="select-arrow"></span>
                                                                                 <select id="Costbook_assemblycategory_value" name="Costbook[assemblycategory][value]">
                                                                                     <option value="All">All</option>';
     foreach ($categories as $values) {
         $content .= '<option value="' . $values->name . '">' . $values->name . '</option>';
     }
     $content .= '</select>
                                                                         </div>
                                                                     </td>
                                                                 </tr>
                                                                 <tr>
                                                                     <th>
                                                                         <label for="costofgoodssoldassembly">Select COGS</label>
                                                                     </th>
                                                                     <td colspan="1">
                                                                         <div class="hasDropDown">
                                                                             <span class="select-arrow"></span>
                                                                             <select id="Costbook_costofgoodssoldassembly_value" name="Costbook[costofgoodssoldassembly][value][assemblycategory][value]">
                                                                                 <option selected="selected" value="All">All</option>
                                                                                 <option value="Labor">Labor</option>
                                                                                 <option value="Equipment">Equipment</option>
                                                                                 <option value="Material">Material</option>
                                                                                 <option value="Subcontractor">Subcontractor</option>
                                                                                 <option value="Other">Other</option>			
                                                                             </select>
                                                                         </div>
                                                                     </td>
                                                                 </tr>
                                                                 <tr>
                                                                     <td></td>
                                                                     <td colspan="1">
                                                                         <a id="saveyt2" class="attachLoading cancel-button" name="Search" href="#"  style="margin-left:21.7%;">
                                                                             <span class="z-spinner"></span>
                                                                             <span class="z-icon"></span>
                                                                             <span class="z-label">Search</span>
                                                                         </a>
                                                                     </td>
                                                                 </tr>
                                                             </tbody>
                                                         </table>
                                                     </div>
                                                     <div id="result_div"></div>
                                                 </div>
                                                 <div class="float-bar">
                                                     <div class="view-toolbar-container clearfix dock">
                                                         <div class="form-toolbar">
                                                             <a href="#" class="cancel-button" id="GobackLinkActionElement2" onclick="window.location.href = \'/app/index.php/costbook/default/edit?id=' . $_GET['id'] . '\';"><span class="z-label">Go Back</span></a>
                                                             <a href="#" class="cancel-button" name="Cancel" id="CancelLinkActionElement2" ><span class="z-label">Cancel</span></a>
                                                             <a href="#" class="cancel-button" name="save" id="saveyt3" onClick="javascript:saveAssemblyStep2();"><span class="z-label">Next</span></a>
                                                         </div>
                                                     </div>
                                                 </div>
                                             </form>
                                         <div id="modalContainer-edit-form">
                                         </div>
                                     </div>
                                 </div>
                             </div>';
     $content .= $this->renderScripts();
     $this->registerCopyAssemblySearchDataScript();
     return $content;
 }
 function test_deleteAll()
 {
     //Arrange
     $category_name = "Wash the dog";
     $id1 = 1;
     $category_name2 = "Home stuff";
     $id2 = 2;
     $test_category = new Category($category_name, $id1);
     $test_category->save();
     $test_category2 = new Category($category_name2, $id2);
     $test_category2->save();
     //Act
     Category::deleteAll();
     $result = Category::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
 function test_deleteAll()
 {
     //arrange
     $name = "Business";
     $id = null;
     $test_category = new Category($name, $id);
     $test_category->save();
     $name2 = "Personal";
     $test_category2 = new Category($name, $id);
     $test_category2->save();
     //act
     Category::deleteAll();
     //assert
     $result = Category::getAll();
     $this->assertEquals([], $result);
 }
    public function makeCostBookProductSelection($datas, $opportunityId)
    {
        $categories = Category::getAll();
        $TotalDirectCost = 0;
        $content = '<div>';
        $opportunityProducts = OpportunityProduct::getAllByOpptId(intval($opportunityId));
        $opportunity = Opportunity::getById(intval($opportunityId));
        $countOfSelectedRow = 0;
        if ($opportunity->recordType->value == 'Recurring Final') {
            $content .= '<div class="cgrid-view type-opportunityProducts" id="list-view">
                                <div class="summary">
                                    5 result(s)
                                </div>
                                <div id="add_Product_list_table" class="table_border_width">
                                    <table id="add_Product_List_table_Value" class="items">
                                        <tr>
                                            <td><label id="totalMhr"> Total Mhr ' . OpportunityProductUtils::getCurrencyType() . ': 0 </label></td>
                                            <td><label id="totalDirectCost"> Total Direct Cost ' . OpportunityProductUtils::getCurrencyType() . ': 0 </label></td>
                                            <td><label id="budget"> Budget ' . OpportunityProductUtils::getCurrencyType() . ': 0 </label></td>
                                        </tr>
                                        <tr>
                                            <td><label id="Revenue_MHR"> Revenue / MHR ' . OpportunityProductUtils::getCurrencyType() . ': 0.0 </label></td>
                                            <td><label id="Aggregate_GPM"> Aggregate GPM %: 0 </label></td>
                                            <td><label id="Suggested_Price"> Suggested Price ' . OpportunityProductUtils::getCurrencyType() . ': 0 </label></td>
                                        </tr>
                                    </table>
                                </div>';
            if (count($opportunityProducts) > 0) {
                $content .= '<div id="selected_products" class="table_border_width" style="padding: 0%;">
                                        <div class="align_left" style="background-color:#E0D1D1; color:black;padding:0.5%; font-weight:bold;">
                                             Selected Products <span id="showresults" style="color:green; font-weight:none;"></span>
                                        </div>
                                            <div style="margin:0.5% 0% 0.5% 45%">
                                                <a href="#" onclick="javascript:updateSelectedProducts(\'' . $opportunityId . '\');">
                                                    <span class="z-label">
                                                        Update Values
                                                    </span>
                                                </a>
                                            </div>';
                $content .= '<table class="items selected_products_table">
                                                <tr style="color:black; padding:0.5%;">
                                                    <th>Product Code</th>
                                                    <th>Product Name</th>
                                                    <th>Unit of Measure</th>
                                                    <th>Quantity</th>
                                                    <th>Frequency</th>
                                                    <th>MH</th>
                                                    <th>L+B</th>
                                                    <th>M</th>
                                                    <th>E</th>
                                                    <th>S</th>
                                                    <th>O</th>
                                                    <th>Total Direct Cost</th>
                                                </tr>';
                foreach ($opportunityProducts as $row) {
                    $opportunityPdctMap[$row->Category][] = $row;
                }
                $CategoryKeyCount = 0;
                $totalMhr = 0;
                $totalDirectCost = 0;
                $totalFinalPrice = 0.0;
                $actualGPM = 0;
                $totalRevenue = 0.0;
                foreach ($opportunityPdctMap as $CategoryKey => $opportunityArray) {
                    $content .= '<tr>
                                              <th colspan="12" class="align_left" style="background-color:gray;color:white;">' . $CategoryKey . '</th>
                                              <input type="hidden" name="CategoryKey" id="CategoryKey_' . $CategoryKeyCount . '" value="' . $CategoryKey . '">
                                            </tr>';
                    foreach ($opportunityArray as $opportunityKey => $opportunitypdt) {
                        $totalMhr += $opportunitypdt->Total_MHR;
                        $totalDirectCost += $opportunitypdt->Total_Direct_Cost->value;
                        $totalFinalPrice += $opportunitypdt->Final_Cost->value;
                        $content .= '<tr>
                                                <td>' . $opportunitypdt->costbook->productcode . '</td>
                                                <input value=' . $opportunitypdt->id . ' name="list_View_Add_Product_SelectedIds"id="list_View_Producted_SelectedIds_' . $countOfSelectedRow . '" type="hidden">
                                                <td>' . $opportunitypdt->name . '</td>
                                                <td>' . $opportunitypdt->costbook->unitofmeasure . '</td>
                                                <td><input type="text" name="updateFrequency&Quantity" id="updateQuantity_' . $countOfSelectedRow . '" value=' . $opportunitypdt->Quantity . '></td>
                                                <td><input name="updateFrequency&Quantity" type="text" id="updateFrequency_' . $countOfSelectedRow . '" value=' . $opportunitypdt->Frequency . '></td>
                                                <td>' . $opportunitypdt->Total_MHR . '</td>
                                                <td>' . OpportunityProductUtils::getCurrencyType() . ($opportunitypdt->Labor_Cost->value + $opportunitypdt->Burden_Cost->value) . '</td>
                                                <td>' . OpportunityProductUtils::getCurrencyType() . $opportunitypdt->Materials_Cost . '</td>
                                                <td>' . OpportunityProductUtils::getCurrencyType() . $opportunitypdt->Equipment_Cost . '</td>
                                                <td>' . OpportunityProductUtils::getCurrencyType() . $opportunitypdt->Sub_Cost . '</td>
                                                <td>' . OpportunityProductUtils::getCurrencyType() . $opportunitypdt->Other_Cost . '</td>
                                                <td>' . OpportunityProductUtils::getCurrencyType() . $opportunitypdt->Total_Direct_Cost->value . '</td>
                                            </tr>';
                        $countOfSelectedRow++;
                    }
                    $CategoryKeyCount++;
                }
                if ($totalFinalPrice > 0) {
                    $actualGPM = ($totalFinalPrice - $totalDirectCost) / $totalFinalPrice * 100;
                }
                if ($totalMhr > 0) {
                    $totalRevenue = $totalFinalPrice / $totalMhr;
                }
                Yii::app()->clientScript->registerScript('calculationForAddProductScreenRecurring', '$("#totalMhr").text("Total Mhr ' . OpportunityProductUtils::getCurrencyType() . ': ' . $totalMhr . '");
                                         $("#totalDirectCost").text("Total Direct Cost ' . OpportunityProductUtils::getCurrencyType() . ': ' . $totalDirectCost . '");   
                                         $("#budget").text("Budget ' . OpportunityProductUtils::getCurrencyType() . ' : ' . $opportunity->budget->value . '");
                                         $("#Suggested_Price").text("Suggested Price ' . OpportunityProductUtils::getCurrencyType() . ': ' . sprintf('%.2f', $totalFinalPrice) . '");
					 $("#Aggregate_GPM").text("Aggregate GPM %: ' . sprintf('%.2f', $actualGPM) . '");
                                         //$("#Roundedvalue").text(" Rounded value").css({"color":"red"});    
					 $("#Revenue_MHR").text("Revenue / MHR ' . OpportunityProductUtils::getCurrencyType() . ': ' . sprintf('%.2f', $totalRevenue) . '");    
                                     ');
                $content .= '<input value="' . $countOfSelectedRow . '" name="Selected_Products_Ids" id="Selected_Products_Ids" type="hidden">';
                $content .= ' </table></div></td></tr></table></div>';
            }
            $content .= '<div class="table_border_width" id="add_product_search" style="padding: 0px;">
                                         <div class="panel">
                                            <div class="align_left" style="color:black; background-color:#E0D1D1; color:black; padding:0.5%; font-weight:bold;">Search</div>
                                            <table class="form-fields">
                                                <colgroup><col class="col-0"><col class="col-1"></colgroup>
                                                <tbody>
                                                    <tr>
                                                        <th width="20%">
                                                            <label for="oppt_AddProductcategory_value">Select Category</label>
                                                        </th>
                                                        <td colspan="1" >
                                                            <div class="hasDropDown">
                                                                <span class="select-arrow"></span>
                                                                    <select id="oppt_AddProductcategory_value" name="Costbook[assemblycategory][value]">
                                                                        <option value="All">All</option>';
            foreach ($categories as $values) {
                $content .= '<option value="' . $values->name . '">' . $values->name . '</option>';
            }
            $content .= '</select>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>
                                                            <label for="costofgoodssoldassembly">Select COGS</label>
                                                        </th>
                                                        <td colspan="1" style="margin: 0px;">
                                                            <div class="hasDropDown">
                                                                <span class="select-arrow"></span>
                                                                    <select id="oppt_AddProductcostofgoodssold_value" name="Costbook[costofgoodssoldassembly][value][assemblycategory][value]">
                                                                        <option selected="selected" value="All">All</option>
                                                                        <option value="Labor">Labor</option>
                                                                        <option value="Equipment">Equipment</option>
                                                                        <option value="Material">Material</option>
                                                                        <option value="Subcontractor">Subcontractor</option>
                                                                        <option value="Other">Other</option>            
                                                                    </select>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <label for="costofgoodssoldassembly"></label>
                                                        </td>
                                                        <td colspan="1">
                                                        <div style="margin-left:32%;">                                                            
                                                            <a id="search" onClick="javascript:searchProducts(\'' . $opportunityId . '\');" class="attachLoading z-button cancel-button" name="Search" href="#">
                                                                <span class="z-spinner"></span>
                                                                <span class="z-icon"></span>
                                                                <span class="z-label">Search</span>
                                                            </a>
                                                        </div>    
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                         </div>
                                         <div id="result_div"></div>
                                     </div>
                                </div>';
            $content .= OpportunityProductUtils::appendButton($opportunityId);
            $content .= '<div class="items-wrapper" id="addProductWrapper">
                       <input type="hidden" id="selectedProductCnt" value="' . $countOfSelectedRow . '" />    
                                        <div id="searchProducts">';
        } else {
            $content .= '<div class="cgrid-view type-opportunityProducts" id="list-view">
                                <div class="summary">
                                    5 result(s)
                                </div>
                                <div id="add_product_outer">
                                    <div id="add_Product_list_table" class="table_border_width">
                                        <table id="add_Product_List_table_Value" class="items">
                                            <tr>
                                                <td><label id="totalMhr"> Total Mhr ' . OpportunityProductUtils::getCurrencyType() . ': 0 </label></td>
                                                <td><label id="totalDirectCost"> Total Direct Cost ' . OpportunityProductUtils::getCurrencyType() . ': 0 </label></td>
                                                <td><label id="budget"> Budget ' . OpportunityProductUtils::getCurrencyType() . ': 0 </label></td>
                                            </tr>
                                            <tr>
                                                <td><label id="Revenue_MHR"> Revenue / MHR ' . OpportunityProductUtils::getCurrencyType() . ': 0.0 </label></td>
                                                <td><label id="Aggregate_GPM"> Aggregate GPM %: 0 </label></td>
                                                <td><label id="Suggested_Price"> Suggested Price ' . OpportunityProductUtils::getCurrencyType() . ': 0 </label></td>
                                            </tr>
                                        </table>
                                    </div>';
            if (count($opportunityProducts) > 0) {
                $content .= '<div id="selected_products" class="table_border_width" style="padding: 0px;">
                                    
                                        <div class="align_left" style="background-color:#E0D1D1; color:black;padding:0.5%; font-weight:bold;">
                                             Selected Products <span id="showresults" style="color:green; font-weight:none;"></span>
                                        </div>
                                            <div style="margin:0.5% 0% 0.5% 45%">
                                                <a href="#" onclick="javascript:updateSelectedProducts(\'' . $opportunityId . '\');">
                                                    <span class="z-label">
                                                        Update Values
                                                    </span>
                                                </a>
                                            </div>';
                $content .= '<table class="items selected_products_table">
                                                <tr style="color:black; padding:0.5%;">
                                                    <th>Product Code</th>
                                                    <th>Product Name</th>
                                                    <th>Unit of Measure</th>
                                                    <th>Quantity</th>
                                                    <th>MH</th>
                                                    <th>L+B</th>
                                                    <th>M</th>
                                                    <th>E</th>
                                                    <th>S</th>
                                                    <th>O</th>
                                                    <th>Total Direct Cost</th>
                                                </tr>';
                foreach ($opportunityProducts as $row) {
                    $opportunityPdctMap[$row->Category][] = $row;
                }
                $CategoryKeyCount = 0;
                $totalMhr = 0;
                $totalDirectCost = 0;
                $totalFinalPrice = 0.0;
                $actualGPM = 0;
                $totalRevenue = 0.0;
                foreach ($opportunityPdctMap as $CategoryKey => $opportunityArray) {
                    $content .= '<tr>
                                              <th colspan="11" class="align_left" style="background-color:gray; color:white;">' . $CategoryKey . '</th>
                                              <input type="hidden" name="CategoryKey" id="CategoryKey_' . $CategoryKeyCount . '" value="' . $CategoryKey . '">
                                            </tr>';
                    foreach ($opportunityArray as $opportunityKey => $opportunitypdt) {
                        $totalMhr += $opportunitypdt->Total_MHR;
                        $totalDirectCost += $opportunitypdt->Total_Direct_Cost->value;
                        $totalFinalPrice += $opportunitypdt->Final_Cost->value;
                        $content .= '<tr>
                                                <td>' . $opportunitypdt->costbook->productcode . '</td>
                                                <input value=' . $opportunitypdt->costbook->productcode . ' name="productCode" id="productCode_' . $countOfSelectedRow . '" type="hidden">    
                                                <input value=' . $opportunitypdt->id . ' name="list_View_Add_Product_SelectedIds"id="list_View_Producted_SelectedIds_' . $countOfSelectedRow . '" type="hidden">
                                                <td>' . $opportunitypdt->name . '</td>
                                                <td>' . $opportunitypdt->costbook->unitofmeasure . '</td>
                                                <td><input type="text" id="updateQuantity_' . $countOfSelectedRow . '" value=' . $opportunitypdt->Quantity . '></td>
                                                <td>' . $opportunitypdt->Total_MHR . '</td>    
                                                <td>' . OpportunityProductUtils::getCurrencyType() . ($opportunitypdt->Labor_Cost->value + $opportunitypdt->Burden_Cost->value) . '</td>
                                                <td>' . OpportunityProductUtils::getCurrencyType() . $opportunitypdt->Materials_Cost . '</td>
                                                <td>' . OpportunityProductUtils::getCurrencyType() . $opportunitypdt->Equipment_Cost . '</td>
                                                <td>' . OpportunityProductUtils::getCurrencyType() . $opportunitypdt->Sub_Cost . '</td>
                                                <td>' . OpportunityProductUtils::getCurrencyType() . $opportunitypdt->Other_Cost . '</td>
                                                <td>' . OpportunityProductUtils::getCurrencyType() . $opportunitypdt->Total_Direct_Cost->value . '</td>
                                            </tr>';
                        $countOfSelectedRow++;
                    }
                    $CategoryKeyCount++;
                }
                if ($totalFinalPrice > 0) {
                    $actualGPM = ($totalFinalPrice - $totalDirectCost) / $totalFinalPrice * 100;
                }
                if ($totalMhr > 0) {
                    $totalRevenue = $totalFinalPrice / $totalMhr;
                }
                Yii::app()->clientScript->registerScript('calculationForAddProductScreen', '$("#totalMhr").text("Total Mhr ' . OpportunityProductUtils::getCurrencyType() . ': ' . $totalMhr . '");
                                         $("#totalDirectCost").text("Total Direct Cost ' . OpportunityProductUtils::getCurrencyType() . ': ' . $totalDirectCost . '");   
                                         $("#budget").text("Budget ' . OpportunityProductUtils::getCurrencyType() . ': ' . $opportunity->budget->value . '");   
					 $("#Suggested_Price").text("Suggested Price ' . OpportunityProductUtils::getCurrencyType() . ': ' . sprintf('%.2f', $totalFinalPrice) . '");
					 $("#Aggregate_GPM").text("Aggregate GPM %: ' . sprintf('%.2f', $actualGPM) . '");
                                         //$("#Roundedvalue").text(" Rounded value").css({"color":"red"});
					 $("#Revenue_MHR").text("Revenue / MHR ' . OpportunityProductUtils::getCurrencyType() . ': ' . sprintf('%.2f', $totalRevenue) . '");
                                        //alert("' . $totalMhr . '");
                                     ');
                $content .= '<input value="' . $countOfSelectedRow . '" name="Selected_Products_Ids" id="Selected_Products_Ids" type="hidden">';
                $content .= ' </table></div></td></tr></table></div>
                            </div>';
            }
            $content .= '<div class="table_border_width" id="add_product_search" style="padding: 0px;">
                                         <div class="panel">
                                            <div class="align_left" style="color:black; background-color:#E0D1D1; color:black; padding:0.5%; font-weight:bold;">Search</div>
                                            <table class="form-fields items">
                                                <colgroup><col class="col-0"><col class="col-1"></colgroup>
                                                <tbody>
                                                    <tr>
                                                        <th width="20%">
                                                            <label for="oppt_AddProductcategory_value">Select Category</label>
                                                        </th>
                                                        <td colspan="1">
                                                            <div class="hasDropDown">
                                                                <span class="select-arrow"></span>
                                                                    <select id="oppt_AddProductcategory_value" name="Costbook[assemblycategory][value]">
                                                                        <option value="All">All</option>';
            foreach ($categories as $values) {
                $content .= '<option value="' . $values->name . '">' . $values->name . '</option>';
            }
            $content .= '</select>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <th>
                                                            <label for="costofgoodssoldassembly">Select COGS</label>
                                                        </th>
                                                        <td colspan="1">
                                                            <div class="hasDropDown">
                                                                <span class="select-arrow"></span>
                                                                    <select id="oppt_AddProductcostofgoodssold_value" name="Costbook[costofgoodssoldassembly][value][assemblycategory][value]">
                                                                        <option selected="selected" value="All">All</option>
                                                                        <option value="Labor">Labor</option>
                                                                        <option value="Equipment">Equipment</option>
                                                                        <option value="Material">Material</option>
                                                                        <option value="Subcontractor">Subcontractor</option>
                                                                        <option value="Other">Other</option>            
                                                                    </select>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <label for="costofgoodssoldassembly"></label>
                                                        </td>
                                                        <td colspan="1">
                                                        <div style="margin-left:32%;">    
                                                            <a id="search" onclick="javascript:searchProducts(\'' . $opportunityId . '\');" class="attachLoading cancel-button" name="Search" href="#">
                                                                <span class="z-spinner"></span>
                                                                <span class="z-icon"></span>
                                                                <span class="z-label">Search</span>
                                                            </a>
                                                        </div>    
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                         </div>
                                         <div id="result_div"></div>
                                     </div>';
            $content .= OpportunityProductUtils::appendButton($opportunityId);
            $content .= '<div class="items-wrapper" id="addProductWrapper">
                       <input type="hidden" id="selectedProductCnt" value="' . $countOfSelectedRow . '" />
                       <div id="searchProducts"><a id="" href="searchResult"></a>';
        }
        $count = 0;
        $content1 = '';
        if ($opportunity->recordType->value == 'Recurring Final') {
            foreach ($datas as $data) {
                $dispCategory = OpportunityProductUtils::makeDropDownByCategory($data->category, $count, $opportunityId, $data->productcode);
                $count++;
            }
        } else {
            foreach ($datas as $data) {
                $dispCategory = OpportunityProductUtils::makeDropDownByCategory($data->category, $count, $opportunityId, $data->productcode);
                $count++;
            }
        }
        $content .= '</tbody>
                         </table>
                            <input value="" name="list-view-selectedIds" id="list-view-selectedIds" type="hidden">
                         </div>
                         </div></div>
                         <input value="' . $opportunity->recordType->value . '" name="recordType" id="recordType_Ids" type="hidden">';
        return $content;
    }
Example #20
0
        }
    }
    if (isset($_POST['category_id'])) {
        if ($_POST['category_id'] != 0) {
            $category_id = $_POST['category_id'];
            $options .= " AND category_id = '" . $_POST['category_id'] . "'";
        }
    }
    if (isset($_POST['station'])) {
        if ($_POST['station'] != 0) {
            $station = $_POST['station'];
            $options .= " AND channel_id = '" . $_POST['station'] . "'";
        }
    }
}
try {
    $db = DB::conn();
    $channels = $db->rows('SELECT * FROM ' . Channel::TABLE);
    $smarty = new Smarty();
    $smarty->template_dir = dirname(dirname(__FILE__)) . '/templates/';
    $smarty->compile_dir = dirname(dirname(__FILE__)) . '/templates_c/';
    $smarty->assign('sitetitle', '録画済一覧');
    $smarty->assign('records', Reserve::getRecordedItems($options));
    $smarty->assign('search', $search);
    $smarty->assign('channels', $channels);
    $smarty->assign('categories', Category::getAll());
    $smarty->assign('use_thumbs', $settings->use_thumbs);
    $smarty->display("recordedTable.html");
} catch (exception $e) {
    throw $e;
}
Example #21
0
     <div class="content_item">
        <h2>Postavljanje novog bloga</h2>
        <form class="form" method="post" action="publishblog.php" id="blogForm">
          <label>Naslov:</label><br><input type="text" name="tb_title"><br>
          <label>Kategorija : </label><select name="sel_category">
          								<?php 
$blogCat = Category::getAll();
foreach ($blogCat as $value) {
    echo "<option value='{$value->category_id}'>" . $value->name . "</option>";
}
?>
      								</select><br><br>	
          <label>Tekst bloga:</label><br><textarea rows="20" cols="90" name="ta_blog" form="blogForm"></textarea><br>	
          <input type="hidden" name="user_id" value="<?php 
echo $_SESSION['user_id'];
?>
">
          <input id="btn" type="submit" value="Postavi Blog" name="btn_submit">
        </form>

      </div><!--close content_item-->
        <br style="clear:both"/> 
      </div><!--close content-->    
Example #22
0
 function testDeleteCategory()
 {
     //Arrange
     $name = "Work Stuff";
     $id = 1;
     $test_category = new Category($name, $id);
     $test_category->save();
     $name2 = "Home Stuff";
     $id2 = 2;
     $test_category2 = new Category($name2, $id2);
     $test_category2->save();
     //Act
     $test_category->delete();
     //Assert
     $this->assertEquals([$test_category2], Category::getAll());
 }
 function testUpdate()
 {
     $category_name = "music";
     $new_category = new Category($category_name);
     $new_category->save();
     $new_category->setCategoryName("concerts");
     $new_category->update();
     $result = Category::getAll();
     $this->assertEquals($new_category, $result[0]);
 }
Example #24
0
    $description = $_POST['description'];
    $task = new Task($description);
    $task->save();
    return $app['twig']->render('tasks.html.twig', array('tasks' => Task::getAll()));
});
$app->get("/tasks/{id}", function ($id) use($app) {
    $task = Task::find($id);
    return $app['twig']->render('task.html.twig', array('task' => $task, 'categories' => $task->getCategories(), 'all_categories' => Category::getAll()));
});
$app->post("/categories", function () use($app) {
    $category = new Category($_POST['name']);
    $category->save();
    return $app['twig']->render('categories.html.twig', array('categories' => Category::getAll()));
});
$app->get("/categories/{id}", function ($id) use($app) {
    $category = Category::find($id);
    return $app['twig']->render('category.html.twig', array('category' => $category, 'tasks' => $category->getTasks(), 'all_tasks' => Task::getAll()));
});
$app->post("/add_tasks", function () use($app) {
    $category = Category::find($_POST['category_id']);
    $task = Task::find($_POST['task_id']);
    $category->addTask($task);
    return $app['twig']->render('category.html.twig', array('category' => $category, 'categories' => Category::getAll(), 'tasks' => $category->getTasks(), 'all_tasks' => Task::getAll()));
});
$app->post("/add_categories", function () use($app) {
    $category = Category::find($_POST['category_id']);
    $task = Task::find($_POST['task_id']);
    $task->addCategory($category);
    return $app['twig']->render('task.html.twig', array('task' => $task, 'tasks' => Task::getAll(), 'categories' => $task->getCategories(), 'all_categories' => Category::getAll()));
});
return $app;
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $categories = $this->categoryRepository->getAll();
     return $this->render('admin.categories.index', compact('categories'));
 }
Example #26
0
    $category = Category::find($id);
    return $app['twig']->render('category.html.twig', array('category' => $category, 'tasks' => $category->getTasks()));
});
$app->post("/tasks", function () use($app) {
    $description = $_POST['description'];
    $category_id = $_POST['category_id'];
    $due_date = $_POST['due_date'];
    $task = new Task($description, $id = null, $category_id, $due_date);
    $task->save();
    $category = Category::find($category_id);
    return $app['twig']->render('category.html.twig', array('category' => $category, 'tasks' => $category->getTasks()));
});
$app->post("/categories", function () use($app) {
    $category = new Category($_POST['name']);
    $category->save();
    return $app['twig']->render('index.html.twig', array('categories' => Category::getAll()));
});
$app->post("/delete_categories", function () use($app) {
    Task::deleteAll();
    Category::deleteAll();
    return $app['twig']->render('index.html.twig', array('categories' => Category::getAll()));
});
$app->post("/delete_tasks", function () use($app) {
    $category_id = $_POST['category_id'];
    Task::deleteTasks($category_id);
    return $app['twig']->render('index.html.twig', array('categories' => Category::getAll()));
});
$app->get("/all_tasks", function () use($app) {
    return $app['twig']->render('all_tasks.html.twig', array('tasks' => Task::getAll(), 'categories' => Category::getAll()));
});
return $app;
Example #27
0
            <td><input type='email' name='email' class='form-control' placeholder="Enter Email Address " required></td>
        </tr>

        <tr>
            <td>Mobile Number</td>
            <td><input type='number' name='mobile' class='form-control' placeholder="Enter Mobile Number" required></td>
        </tr>

        <tr>
            <td>Category</td>
            <td>
                <?php 
// choose user categories
include_once 'classes/category.php';
$category = new Category($db);
$prep_state = $category->getAll();
echo "<select class='form-control' name='category_id'>";
echo "<option>--- Select Category ---</option>";
while ($row_category = $prep_state->fetch(PDO::FETCH_ASSOC)) {
    extract($row_category);
    echo "<option value='{$id}'> {$name} </option>";
}
echo "</select>";
?>
            </td>
        </tr>

        <tr>
            <td></td>
            <td>
                <button type="submit" class="btn btn-primary">
 /**
  * 分类页
  */
 public function actionIndex()
 {
     $Category = new Category();
     $this->list = $Category->getAll();
 }
Example #29
0
$password = '******';
$DB = new PDO($server, $username, $password);
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig');
});
$app->get("/tasks", function () use($app) {
    return $app['twig']->render('tasks.html.twig', array('tasks' => Task::getAll()));
});
$app->get("/categories", function () use($app) {
    return $app['twig']->render('categories.html.twig', array('categories' => Category::getAll()));
});
$app->post("/tasks", function () use($app) {
    $task = new task($_POST['description']);
    $task->save();
    return $app['twig']->render('tasks.html.twig', array('tasks' => Task::getAll()));
});
$app->post("/delete_tasks", function () use($app) {
    Task::deleteAll();
    return $app['twig']->render('index.html.twig');
});
$app->post("/categories", function () use($app) {
    $category = new Category($_POST['name']);
    $category->save();
    return $app['twig']->render('categories.html.twig', array('categories' => Category::getAll()));
});
$app->post("/delete_categories", function () use($app) {
    Category::deleteAll();
    return $app['twig']->render('index.html.twig');
});
return $app;
Example #30
0
?>
"><?php 
echo $author->getFullName();
?>
</a></td></tr><?
      } ?>
    </table>
<? } ?>

<p>
<? if (sizeof($all) > 0) { ?>
    <h3><?php 
echo Text::getText("RecipesInCategory");
?>
</h3>
    <? $categories = Category::getAll(); ?>
    <form method="POST" action="<?php 
echo $smellyfish_base_uri;
?>
editAll.php">
        <? if (strlen($cat) != 0) {?>
            <input type="hidden" name="cat" value="<?php 
echo $cat;
?>
">
        <? } ?>
        <p>
        <table border="0" cellpadding="2" cellspacing="0">
            <? $bg = FALSE; ?>
            <? foreach ($all as $r) { ?>
              <? include("recipe_line.php"); ?>