示例#1
0
文件: Menus.php 项目: KokLip/GST
 public static function getItems()
 {
     $items = [];
     $uid = Yii::$app->user->identity->user_id;
     $accessAdmin = Access2::find()->where(['user_id' => $uid, 'sub_module_id' => 1])->one();
     $accessCategory = Access2::find()->where(['user_id' => $uid, 'sub_module_id' => 3])->one();
     $accessProduct = Access2::find()->where(['user_id' => $uid, 'sub_module_id' => 8])->one();
     $accessCustomer = Access2::find()->where(['user_id' => $uid, 'sub_module_id' => 13])->one();
     $accessSupplier = Access2::find()->where(['user_id' => $uid, 'sub_module_id' => 18])->one();
     $accessTax = Access2::find()->where(['user_id' => $uid, 'sub_module_id' => 25])->one();
     $accessQuotation = Access2::find()->where(['user_id' => $uid, 'sub_module_id' => 30])->one();
     $accessPO = Access2::find()->where(['user_id' => $uid, 'sub_module_id' => 35])->one();
     $accessAccess = Access2::find()->where(['user_id' => $uid, 'sub_module_id' => 23])->one();
     if ($accessAdmin != NULL) {
         $modAdmin = Module::find()->where(['module_id' => 1])->one();
         $items[] = ['label' => $modAdmin->module_name, 'url' => [$modAdmin->module_url], 'active' => \Yii::$app->controller->id == $modAdmin->module_tab_active];
     } else {
     }
     if ($accessCategory != NULL) {
         $modCategory = Module::find()->where(['module_id' => 2])->one();
         $items[] = ['label' => $modCategory->module_name, 'url' => [$modCategory->module_url], 'active' => \Yii::$app->controller->id == $modCategory->module_tab_active];
     } else {
     }
     if ($accessProduct != NULL) {
         $modProduct = Module::find()->where(['module_id' => 3])->one();
         $items[] = ['label' => $modProduct->module_name, 'url' => [$modProduct->module_url], 'active' => \Yii::$app->controller->id == $modProduct->module_tab_active];
     } else {
     }
     if ($accessCustomer != NULL) {
         $modCustomer = Module::find()->where(['module_id' => 4])->one();
         $items[] = ['label' => $modCustomer->module_name, 'url' => [$modCustomer->module_url], 'active' => \Yii::$app->controller->id == $modCustomer->module_tab_active];
     } else {
     }
     if ($accessSupplier != NULL) {
         $modSupplier = Module::find()->where(['module_id' => 5])->one();
         $items[] = ['label' => $modSupplier->module_name, 'url' => [$modSupplier->module_url], 'active' => \Yii::$app->controller->id == $modSupplier->module_tab_active];
     } else {
     }
     if ($accessTax != NULL) {
         $modSupplier = Module::find()->where(['module_id' => 6])->one();
         $items[] = ['label' => $modSupplier->module_name, 'url' => [$modSupplier->module_url], 'active' => \Yii::$app->controller->id == $modSupplier->module_tab_active];
     } else {
     }
     if ($accessQuotation != NULL) {
         $modSupplier = Module::find()->where(['module_id' => 7])->one();
         $items[] = ['label' => $modSupplier->module_name, 'url' => [$modSupplier->module_url], 'active' => \Yii::$app->controller->id == $modSupplier->module_tab_active];
     } else {
     }
     if ($accessPO != NULL) {
         $modSupplier = Module::find()->where(['module_id' => 8])->one();
         $items[] = ['label' => $modSupplier->module_name, 'url' => [$modSupplier->module_url], 'active' => \Yii::$app->controller->id == $modSupplier->module_tab_active];
     } else {
     }
     if ($accessAccess != NULL) {
         $modSupplier = Module::find()->where(['module_id' => 9])->one();
         $items[] = ['label' => $modSupplier->module_name, 'url' => [$modSupplier->module_url], 'active' => \Yii::$app->controller->id == $modSupplier->module_tab_active];
     } else {
     }
     return $items;
 }
示例#2
0
 public static function getSecondMenus($module)
 {
     $firstMenu = Module::find()->where(['url' => $module, 'pid' => 0])->asArray()->one();
     $secondMenus = Module::find()->where(['pid' => $firstMenu['id']])->orderBy(['sequenced' => SORT_ASC])->asArray()->all();
     foreach ($secondMenus as $key => $menu) {
         $secondMenus[$key]['defaultUrl'] = $firstMenu['url'] . '/' . $menu['url'];
     }
     return $secondMenus;
 }
示例#3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Module::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'active' => $this->active, 'type_id' => $this->type_id]);
     $query->andFilterWhere(['like', 'iconfa', $this->iconfa])->andFilterWhere(['like', 'label', $this->label])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'controller', $this->controller]);
     return $dataProvider;
 }
示例#4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Module::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'moduleName', $this->moduleName])->andFilterWhere(['like', 'moduleNum', $this->moduleNum]);
     return $dataProvider;
 }
示例#5
0
 public function save(Request $request)
 {
     $as = $request->input('as');
     $module = new Module();
     $permission = new Permission();
     $validator = \Validator::make($request->all(), $module->getRules());
     $results = new \StdClass();
     if ($validator->passes()) {
         if ($request->input('id') != "xxx") {
             $module = Module::find($request->input('id'));
             $module->name = $request->input('name');
             $module->route = $request->input('route');
             $module->description = $request->input('description');
             $module->save();
             $results->info = 'module create';
         } else {
             $module = new Module();
             $permission = new Permission();
             $module->name = $request->input('name');
             $module->route = $request->input('route');
             $module->description = $request->input('description');
             $module->save();
             $permission->name = "can-access-" . $request->input('name');
             $permission->display_name = "Dapat Mengakses " . $request->input('name');
             $results->info = 'module edit';
         }
         $results->status = 1;
         $results->result = $module;
     } else {
         $results->status = 0;
         $result = array();
         foreach ($validator->errors() as $key => $err) {
             array_push($result, $err);
         }
         $results->result = $result;
     }
     return response()->json($results);
 }
示例#6
0
 public function createMenu()
 {
     $menu = "";
     if (!Yii::$app->user->isGuest) {
         $profile = Profile::findOne(Yii::$app->user->identity->profile_id);
         $menu .= "<h2><span class='label label-primary'>{$profile->name}</span></h2>";
         //            $menu .= "<a href='" . Url::toRoute("site/index") . "'><i class='fa fa-fw fa-home'></i><span>Home</span></a>";
         $access = Access::find()->where(["profile_id" => Yii::$app->user->identity->profile_id])->all();
         foreach ($access as $value) {
             $module = Module::find()->where(["id" => $value->module_id])->one();
             $path = "{$module->controller}/index";
             $href = Url::toRoute($path);
             $link = "<a href='{$href}'><i class='fa fa-fw {$module->iconfa}'></i><span>{$module->label}</span></a>";
             $menu .= $link;
         }
     }
     //        if (Yii::$app->user->isGuest) {
     //            $menu .= "<a href='" . Url::toRoute('site/login') . "'><i class='fa fa-fw fa-sign-in'></i><span>Login</span></a>";
     //        } else {
     //            $menu .= "<a href='" . Url::toRoute('site/logout') . "' data-method='post'><i class='fa fa-fw fa-sign-out'></i><span>Logout (" . Yii::$app->user->identity->username . ")</span></a>";
     //        }
     return $menu;
 }
示例#7
0
 public function actionLists($id)
 {
     $countModules = Module::find()->where(['id' => $id])->count();
     $modules = Module::find()->where(['id' => $id])->orderBy('id DESC')->all();
     if ($countModules > 0) {
         foreach ($module as $module) {
             echo "<option value='" . $modules->id . "'>" . $modules->id . "</option>";
         }
     } else {
         echo "<option>-</option>";
     }
 }
示例#8
0
 public function delete($idx)
 {
     Module::find($idx)->delete();
 }
示例#9
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function createExchange()
 {
     $business = Business::all()->first();
     $active = $business->exchange_active;
     $moduleId = $business->gift_module_id;
     $moduloFind = Module::where('id', $moduleId);
     if ($moduleId != NULL) {
         $moduloFind = Module::find($moduleId);
         $modulo = $moduloFind->name;
     } else {
         $modulo = 'No se ha asignado el modulo principal de canjeo de regalos';
     }
     $giftsArr = Gift::all();
     $giftsList = Gift::orderBy('id')->get()->lists('name', 'id');
     $min = Gift::orderBy('id')->get()->lists('id')->first();
     return view('internal.salesman.exchangeGift', ['giftsList' => $giftsList, 'giftArray' => $giftsArr, 'min' => $min, 'active' => $active, 'modulo' => $modulo]);
 }
示例#10
0
<?php

use app\models\Module;
use yii\helpers\Url;
use yii\helpers\Html;
$module = Module::find()->asArray()->all();
$session = Yii::$app->session;
$session->open();
$user_session = $session['session.user'];
$session->close();
?>

<style>
.active{
	background: rgb(3, 169, 245) !important;
}

.diactive{
	background: rgb(51, 51, 51) !important;
}
</style>

<div id = "kotak-logout" style="text-align: right; padding: 15dp">
	<label style="color:white; margin-right:15dp">Welcome <?php 
echo $user_session['username'];
?>
, You're Login as <?php 
echo $user_session['user_type'];
?>
 | </label> <a href="<?php 
echo Yii::$app->urlManager->createUrl("site/logout");
示例#11
0
 public function destroyAssigment($id)
 {
     //
     $moduleassigment = ModuleAssigment::find($id);
     $module = Module::find($moduleassigment->module_id);
     if ($module->openModule == true) {
         return back()->withErrors(['Antes de desasociar al vendedor, primero este debe cerrar su caja']);
     }
     $salesman = User::find($moduleassigment->salesman_id);
     $tickets = DB::table('tickets')->where('salesman_id', '=', $salesman->id)->where('payment_date', '<', new Carbon())->where('payment_date', '>=', Carbon::today())->whereNull('cashCount_register')->get();
     $devolutions = DB::table('devolutions')->where('tickets.salesman_id', '=', $salesman->id)->where('devolutions.created_at', '<', new Carbon())->where('devolutions.created_at', '>=', Carbon::today())->whereNull('devolutions.cashCount_register')->leftJoin('tickets', 'tickets.id', '=', 'devolutions.ticket_id')->get();
     if ($tickets != null) {
         return back()->withErrors(['Antes de desasociar, primero este debe hacer el arqueo de caja']);
     }
     if ($devolutions != null) {
         return back()->withErrors(['Antes de desasociar, primero este debe hacer el arqueo de caja']);
     }
     $moduleassigment->status = 2;
     $moduleassigment->dateMoveAssigments = new Carbon();
     $salesman = User::find($moduleassigment->salesman_id);
     $salesman->module_id = null;
     $salesman->save();
     $moduleassigment->save();
     return redirect('admin/modules/assigment');
 }
示例#12
0
}
?>

    <?php 
ActiveForm::end();
?>

</div>

<?php 
if (!$model->isNewRecord) {
    ?>
    <div class="profile-add-access">
        <div class="form-group">
            <?php 
    echo Html::dropDownList("module", null, ArrayHelper::map(Module::find()->all(), 'id', 'label'), ["prompt" => "Select a module", "id" => "module", "class" => "form-control col-xs-4"]);
    ?>
        </div>
        <div class="form-group">
            <?php 
    echo Html::a('Add Module', null, ['class' => 'form-control btn btn-success', 'title' => Yii::t('yii', 'click to add'), 'onclick' => "\n                if(\$('#module').val() === ''){\n                    alert('Please select a module to be added.');\n                }else{\n                    \$.ajax({\n                    type:'POST',\n                    cache:false,\n                    data: {'module_id':\$('#module').val(),'profile_id':{$model->id}},\n                    url:'" . Url::toRoute("profile/addmodule") . "',\n                    beforeSend: function () {\n                    \n                    },\n                    success:function(data) {\n                        alert(data.message);\n                        \$('.profile-form-accesses').html(data.gridmodules);\n                        reloadevents();\n                    },\n                    complete: function () {\n                        \n                    },\n                    error: function (xhr) {\n                       alert(xhr);\n                    }                    \n                    });return false;\n                }                \n            "]);
    ?>
        </div>
    </div>

    <div class="profile-form-accesses">
        <?php 
    echo GridView::widget(['dataProvider' => $dataprovidermodule, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['attribute' => 'module', 'value' => 'module.label'], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{deletemodule}', 'buttons' => ['deletemodule' => function ($url) {
        return Html::a('<span class="glyphicon glyphicon-trash"></span>', null, ['data-confirm' => 'Are you sure you want to delete this item?', 'class' => "deletemoduleajax"]);
    }]]], 'options' => ['class' => '', 'id' => 'grid-accesses']]);
    ?>
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $module = Module::find($id);
     if (!$module) {
         return response()->json('Le module n\'existe pas.', 404);
     }
     $module->delete();
     return 'Le module a bien été supprimé.';
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CancelledTicketRequest $request, $ticket_id)
 {
     $user_id = Auth::user()->id;
     $input = $request->all();
     if ($input['ticket_id'] != $ticket_id) {
         return redirect('salesman/devolutions');
     }
     $ticket = Ticket::findOrFail($input['ticket_id']);
     if ($ticket->cancelled == 1) {
         Session::flash('message', 'El ticket ya fue cancelado!');
         Session::flash('alert-class', 'alert-danger');
         return redirect('salesman/devolutions');
     }
     if ($ticket->presentation["cancelled"] == 0) {
         Session::flash('message', 'La presentation ' . $ticket->presentation_id . ' no fue cancelado, por lo tanto no se puede realizar devolución');
         Session::flash('alert-class', 'alert-danger');
         return redirect('/salesman/devolutions');
     }
     $module = Module::find(Auth::user()->module_id);
     if ($module->actual_cash < $ticket->total_price) {
         Session::flash('message', 'No tiene fondos en la caja para poder devolver');
         Session::flash('alert-class', 'alert-danger');
         return redirect('/salesman/devolutions');
     }
     $ticket->cancelled = 1;
     $ticket->save();
     $devolution = new Devolution();
     $devolution->ticket_id = $input['ticket_id'];
     $devolution->user_id = $user_id;
     $devolution->repayment = $ticket->total_price;
     if (isset($input['observation'])) {
         $devolution->observation = $input['observation'];
     }
     $devolution->save();
     Session::flash('message', 'Devolución realizado!');
     Session::flash('alert-class', 'alert-success');
     return redirect('/salesman/devolutions');
 }
示例#15
0
?>

<div class="coursemodule-form">

    <?php 
$form = ActiveForm::begin();
?>

    <!-- This lets you select course and module from drop down and add them to 
    courseModule table. NO validation for duplicates -->
    <?php 
echo $form->field($model, 'Course_id')->dropDownList(ArrayHelper::map(Course::find()->all(), 'id', 'courseName'), ['prompt' => 'Select Course']);
?>
    
    <?php 
echo $form->field($model, 'Module_id')->dropDownList(ArrayHelper::map(Module::find()->all(), 'id', 'moduleName'), ['prompt' => 'Select Module']);
?>


    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
 public function updateCash(request $request)
 {
     // $modules = Module::where('id',\Auth::user()->id_module)->get();
     if (Auth::user()->module_id == null) {
         return back()->withErrors(['El vendedor no tiene una caja asignada']);
     }
     if ($request['type'] == 1) {
         $module = Module::find(\Auth::user()->module_id);
         if ($module->openModule == true) {
             return back()->withErrors(['La caja ya está abierta. Ya colocó dinero en la caja']);
         }
         $module->openModule = true;
         $module->initial_cash = $request['cash'];
         $module->actual_cash = $request['cash'];
         $module->save();
     } elseif ($request['type'] == 2) {
         $module = Module::find(\Auth::user()->module_id);
         if ($module->openModule == false) {
             return back()->withErrors(['La caja ya está cerrada. Abrá la caja primero']);
         }
         $module->openModule = false;
         $module->initial_cash = 0;
         $module->actual_cash = 0;
         $module->save();
         $tickets = DB::table('tickets')->where('salesman_id', '=', \Auth::user()->id)->where('payment_date', '<', new Carbon())->where('payment_date', '>=', Carbon::today())->whereNull('cashCount_register')->get();
         $timeNow = new Carbon();
         $devolutions = DB::table('devolutions')->where('devolutions.user_id', '=', \Auth::user()->id)->where('devolutions.created_at', '<', new Carbon())->where('devolutions.created_at', '>=', Carbon::today())->whereNull('devolutions.cashCount_register')->get();
         foreach ($devolutions as $devolution) {
             $devolution->cashCount_register = $timeNow;
             DB::table('devolutions')->where('id', $devolution->id)->update(['cashCount_register' => $timeNow]);
             //$devolution->save();
         }
         foreach ($tickets as $ticket) {
             $ticket->cashCount_register = $timeNow;
             DB::table('tickets')->where('id', $ticket->id)->update(['cashCount_register' => $timeNow]);
             // $ticket->save();
         }
         $cashCount = new CashcountHistorial();
         $cashCount->module_id = \Auth::user()->module_id;
         $cashCount->salesman_id = \Auth::user()->id;
         $cashCount->initial_cash = $request['cashFirst'];
         $cashCount->sales_cash = $request['sumeSale'];
         $cashCount->devolutions_cash = $request['sumeRefound'];
         $cashCount->total_cash = $request['cash'];
         $cashCount->dateCashCount = new Carbon($request['dateCashCount']);
         $cashCount->save();
     }
     return redirect('salesman/cash_count');
 }
示例#17
0
						<?php 
$form = ActiveForm::begin(['id' => 'create-role-form', 'options' => ['class' => 'form-horizontal', 'data-toggle' => 'validator', 'role' => 'form'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-1 control-label']]]);
?>
							<div class="form-group">
				                <label>Role name</label>
				                <input type="text" class="form-control" placeholder="" name="role" required = "required">
				           	</div>
							<!-- <?php 
echo Html::input("text", "role", null, ["placeholder" => "role name", "required" => "required"]);
?>
 -->
							<div class="form-group">
                				<label>Module and it's access rule</label><br>
								<table>
								<?php 
$module = Module::find()->all();
$hakAkses = HakAkses::find()->all();
$i = 0;
foreach ($module as $key => $value) {
    echo "<tr>";
    echo "<td>";
    echo Html::checkbox("module[{$i}][name]", false, ["label" => $value["name"], "value" => $value["id"]]);
    echo "</td>";
    echo "<td>";
    foreach ($hakAkses as $key2 => $value2) {
        echo Html::checkbox("module[{$i}][role][]", false, ["label" => $value2["name"], "value" => $value2["id"]]);
    }
    echo "</td>";
    echo "</tr>";
    $i++;
}
示例#18
0
 /**
  * Display the specified resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function showAssigment()
 {
     $moduleAssigments = ModuleAssigment::all();
     $assiInformation = [];
     foreach ($moduleAssigments as $moduleAssigment) {
         // pueden ser muchos eventos. Necesito información para llenar la tabla
         $module = Module::find($moduleAssigment->module_id);
         $salesman = User::find($moduleAssigment->salesman_id);
         $role = Role::find($salesman->role_id);
         array_push($assiInformation, array($module->name, $salesman->name, $salesman->lastname, $moduleAssigment->dateAssigments, $moduleAssigment->dateMoveAssigments, $role->description));
     }
     //$array_module = [];
     $modules_list = Module::all()->lists('name', 'id');
     $array = ['modules_list' => $modules_list];
     return view('internal.admin.reports.assignment', compact('assiInformation'), $array);
 }