ソースを参照

Support for add_new in sub views

Vijayakrishnan Krishnan 5 年 前
コミット
f22326d7e3

+ 64 - 10
app/Console/Commands/GenerateTreeCommand.php

@@ -122,7 +122,7 @@ class GenerateTreeCommand extends Command
                         }
                         break;
 
-                    case 8: // sub-type declaration
+                    case 8: // sub-type declaration | add_new fields
 
                         if($line === 'ACTIONS' || $line === 'SUB') {
                             $currentSubType = $line;
@@ -133,8 +133,7 @@ class GenerateTreeCommand extends Command
 
                         break;
 
-                    case 12: // ACTIONS | SUB | add_new fields
-
+                    case 12: // ACTIONS | SUB
                         if($currentSubType === 'ACTIONS') {
                             $currentMethod = $currentSubController->addMethod(
                                 "ACTION_" . $line,
@@ -151,15 +150,18 @@ class GenerateTreeCommand extends Command
                             $currentMethod->type = 'sub';
                             $currentMethod->data = [];
                         }
-
                         break;
 
                     case 16: // data for actions and subs
-
                         if(!empty($currentMethod)) {
                             $currentMethod->data[] = $line;
                         }
+                        break;
 
+                    case 20: // SUB add_new fields
+                        if(!empty($currentMethod)) {
+                            $currentMethod->data[] = $line;
+                        }
                         break;
 
                 }
@@ -232,6 +234,41 @@ class GenController {
     public function saveController() {
         $text = file_get_contents(base_path('generatecv/tree-templates/controller.template.php'));
         $code = [];
+
+        // check if any method has a "sub add_new" in it, if yes, add action for the same
+        $newMethods = [];
+//        echo "--------------------------------------\n";
+//        dump($this->name);
+//        echo "--------------------------------------\n";
+        foreach ($this->methods as $method) {
+//            dump($method->name);
+//            dump($method->type);
+//            dump($method->data);
+            if($method->type === 'sub' && count($method->data) > 1 && strpos($method->data[1], 'add_new') === 0) {
+                $methodName = preg_replace("/^SUB_/", "ACTION_", $method->name) . 'AddNew';
+                $methodRoute = str_replace("/SUB_", "/ACTION_", $method->route) . 'AddNew';
+                $newMethod = new GenControllerMethod($methodName, $methodRoute);
+                $newMethod->hasUID = true;
+                $newMethod->redirect = false;
+                $newMethod->type = 'action';
+                $newMethod->data = [];
+                for($i = 2; $i<count($method->data); $i++) {
+                    $newMethod->data[] = $method->data[$i];
+                }
+                $newMethod->parentSub = $this->name . '-' . $method->name;
+                $newMethod->table = explode(":", $method->data[1])[1];
+                $newMethods[] = $newMethod;
+                $method->childAddRoute = $this->name . '-' . $methodName;
+            }
+        }
+        $this->methods = array_merge($this->methods, $newMethods);
+
+//        foreach ($this->methods as $method) {
+//            dump($method->name);
+//            dump($method->type);
+//            dump($method->data);
+//        }
+
         foreach ($this->methods as $method) {
             $code[] = "";
             $code[] = "\t// GET {$method->route}";
@@ -394,8 +431,21 @@ class GenController {
         $text = file_get_contents(base_path('generatecv/tree-templates/sub-action.template.blade.php'));
         $text = str_replace("_LAYOUT_", "{$controller->root}.{$controller->parentControllerName}.view", $text);
         $text = str_replace("_NAME_", $this->camelToTitleCase($this->snakeToTitleCase($method->name)), $text);
-        $text = str_replace("_BACK_ROUTE_", "{$controller->parentControllerName}-view", $text);
-        $text = str_replace("_API_", "/api/{$controller->dbTable}/" . substr($method->name, 7), $text);
+
+        if(!$method->parentSub) {
+            $text = str_replace("_BACK_ROUTE_", "{$controller->parentControllerName}-view", $text);
+        }
+        else {
+            $text = str_replace("_BACK_ROUTE_", $method->parentSub, $text);
+        }
+
+        if(!$method->table) {
+            $text = str_replace("_API_", "/api/{$controller->dbTable}/" . substr($method->name, 7), $text);
+        }
+        else {
+            $text = str_replace("_API_", "/api/{$method->table}/create", $text);
+        }
+
         $text = str_replace("_RETURN_ROUTE_", "{$controller->name}-{$method->name}", $text);
         $fields = [];
         if(count($method->data)) {
@@ -412,11 +462,12 @@ class GenController {
         $text = str_replace("_LAYOUT_", "{$controller->root}.{$controller->parentControllerName}.view", $text);
         $text = str_replace("_NAME_", $this->camelToTitleCase($this->snakeToTitleCase($method->name)), $text);
 
-        /*if($controller->hasAdd) {
-            $addLink = "<a class='btn btn-primary btn-sm' href='/{$controller->name}/add_new'>" .
+        if(count($method->data) > 1 && $method->data[1] === 'add_new') {
+            $addLink = '<a class="btn btn-primary btn-sm" ' .
+                    'href="{{route(\'' . $method->childAddRoute . '\', [\'uid\' => $record->uid])}}">' .
                 "<i class='fa fa-plus-circle' aria-hidden='true'></i> Add New</a>";
             $text = str_replace("<!-- _ADD_NEW_LINK_ -->", $addLink, $text);
-        }*/
+        }
 
         $dbParts = explode("=", $method->data[0]);
         $dbParts = explode(".", $dbParts[1]);
@@ -588,6 +639,9 @@ class GenControllerMethod {
     public $redirect = false;
     public $type = '';
     public $data = [];
+    public $parentSub = false;
+    public $childAddRoute = false;
+    public $table = false;
     public function __construct($name, $route)
     {
         $this->name = $name;

+ 6 - 0
app/Http/Controllers/my_clients_SINGLE_Controller.php

@@ -329,4 +329,10 @@ class my_clients_SINGLE_Controller extends Controller
 		$record = DB::table('client')->where('uid', $uid)->first();
 		return view('pro/my_clients_SINGLE/SUB_audit_log', compact('record'));
 	}
+
+	// GET /my_clients/view/{uid}/ACTION_notesAddNew
+	public function ACTION_notesAddNew(Request $request, $uid) {
+		$record = DB::table('client')->where('uid', $uid)->first();
+		return view('pro/my_clients_SINGLE/ACTION_notesAddNew', compact('record'));
+	}
 }

+ 1 - 1
generatecv/tree-templates/sub-index.template.blade.php

@@ -3,7 +3,7 @@
 
     <div class="mr-3 pb-3">
 
-        <h4 class='my-3'>
+        <h4 class='my-3 d-flex'>
             <div>_NAME_</div>
             <div class="ml-auto">
                 <!-- _ADD_NEW_LINK_ -->

+ 14 - 1
generatecv/tree.txt

@@ -144,7 +144,20 @@ PRO
                 id=client_pro_access.client_id
             notes
                 id=note.client_id
-#           notes/add_new
+                add_new:note
+                    clientUid:record:client:uid,name_display
+                    hcpProUid:record:pro:uid,name_display
+                    allyProUid:record:pro:uid,name_display
+                    effectiveDateEST:date
+                    effectiveTime:time
+                    reason1
+                    reason2
+                    reason3
+                    reason3Plus
+                    serviceLocation
+                    category
+                    contentText
+                    contentDetail
             care_months
                 id=care_month.client_id
 #           care_months/add_new

+ 2 - 1
resources/views/pro/my_clients/actions.blade.php

@@ -35,4 +35,5 @@
 <a href='/my_clients/view/<?= $record->uid ?>/ACTION_deactivate' class='d-block btn btn-sm btn-default mb-3'>Deactivate</a>
 <a href='/my_clients/view/<?= $record->uid ?>/ACTION_updateDeactivationMemo' class='d-block btn btn-sm btn-default mb-3'>Update Deactivation Memo</a>
 <a href='/my_clients/view/<?= $record->uid ?>/ACTION_reactivate' class='d-block btn btn-sm btn-default mb-3'>Reactivate</a>
-<a href='/my_clients/view/<?= $record->uid ?>/ACTION_updateReactivationMemo' class='d-block btn btn-sm btn-default mb-3'>Update Reactivation Memo</a>
+<a href='/my_clients/view/<?= $record->uid ?>/ACTION_updateReactivationMemo' class='d-block btn btn-sm btn-default mb-3'>Update Reactivation Memo</a>
+<a href='/my_clients/view/<?= $record->uid ?>/ACTION_notesAddNew' class='d-block btn btn-sm btn-default mb-3'>Notes Add New</a>

+ 97 - 0
resources/views/pro/my_clients_SINGLE/ACTION_notesAddNew.blade.php

@@ -0,0 +1,97 @@
+@extends('pro.my_clients.view')
+@section('content-inner')
+
+    <h4 class='my-3'>
+        <div>Notes Add New</div>
+    </h4>
+
+    <form action="/post-to-api"
+          method="post" enctype="multipart/form-data"
+          class="bg-light rounded border px-3 pt-3 mr-3 mb-3">
+        @csrf
+
+        @if (session('message'))
+            <div class="alert alert-danger">{{ session('message') }}</div>
+        @endif
+
+        <input type="hidden" name="_uid" value="{{ $record->uid }}">
+        <input type="hidden" name="_api" value="/api/note/create">
+        <input type="hidden" name="_success" value="{{route('my_clients_SINGLE-SUB_notes', ['uid' => $record->uid])}}">
+        <input type="hidden" name="_return" value="{{route('my_clients_SINGLE-ACTION_notesAddNew', ['uid' => $record->uid])}}">
+        <div class='form-group mb-3'>
+<label class='control-label'>Client Uid</label>
+<select class='form-control' name='clientUid'>
+<option value=''>-- Select --</option>
+<?php $dbOptions = \Illuminate\Support\Facades\DB::table('client')->get(); ?>
+<?php foreach($dbOptions as $o): ?>
+<option value='<?= $o->uid ?>'><?= $o->name_display ?> (<?= $o->uid ?>)</option>
+<?php endforeach; ?>
+</select>
+</div>
+<div class='form-group mb-3'>
+<label class='control-label'>Hcp Pro Uid</label>
+<select class='form-control' name='hcpProUid'>
+<option value=''>-- Select --</option>
+<?php $dbOptions = \Illuminate\Support\Facades\DB::table('pro')->get(); ?>
+<?php foreach($dbOptions as $o): ?>
+<option value='<?= $o->uid ?>'><?= $o->name_display ?> (<?= $o->uid ?>)</option>
+<?php endforeach; ?>
+</select>
+</div>
+<div class='form-group mb-3'>
+<label class='control-label'>Ally Pro Uid</label>
+<select class='form-control' name='allyProUid'>
+<option value=''>-- Select --</option>
+<?php $dbOptions = \Illuminate\Support\Facades\DB::table('pro')->get(); ?>
+<?php foreach($dbOptions as $o): ?>
+<option value='<?= $o->uid ?>'><?= $o->name_display ?> (<?= $o->uid ?>)</option>
+<?php endforeach; ?>
+</select>
+</div>
+<div class='form-group mb-3'>
+<label class='control-label'>Effective Date EST</label>
+<input class='form-control' type='date' name='effectiveDateEST'>
+</div>
+<div class='form-group mb-3'>
+<label class='control-label'>Effective Time</label>
+<input class='form-control' type='time' name='effectiveTime'>
+</div>
+<div class='form-group mb-3'>
+<label class='control-label'>Reason 1</label>
+<input class='form-control' type='text' name='reason1'>
+</div>
+<div class='form-group mb-3'>
+<label class='control-label'>Reason 2</label>
+<input class='form-control' type='text' name='reason2'>
+</div>
+<div class='form-group mb-3'>
+<label class='control-label'>Reason 3</label>
+<input class='form-control' type='text' name='reason3'>
+</div>
+<div class='form-group mb-3'>
+<label class='control-label'>Reason 3Plus</label>
+<input class='form-control' type='text' name='reason3Plus'>
+</div>
+<div class='form-group mb-3'>
+<label class='control-label'>Service Location</label>
+<input class='form-control' type='text' name='serviceLocation'>
+</div>
+<div class='form-group mb-3'>
+<label class='control-label'>Category</label>
+<input class='form-control' type='text' name='category'>
+</div>
+<div class='form-group mb-3'>
+<label class='control-label'>Content Text</label>
+<input class='form-control' type='text' name='contentText'>
+</div>
+<div class='form-group mb-3'>
+<label class='control-label'>Content Detail</label>
+<input class='form-control' type='text' name='contentDetail'>
+</div>
+        <div class="form-group mb-3">
+            <button class="btn btn-sm btn-primary mr-3 px-5">Submit</button>
+            <a href="{{route('my_clients_SINGLE-SUB_notes', ['uid' => $record->uid])}}" class="btn btn-sm btn-default px-5">Cancel</a>
+        </div>
+    </form>
+
+@endsection

+ 1 - 1
resources/views/pro/my_clients_SINGLE/SUB_action_items.blade.php

@@ -3,7 +3,7 @@
 
     <div class="mr-3 pb-3">
 
-        <h4 class='my-3'>
+        <h4 class='my-3 d-flex'>
             <div>Action Items</div>
             <div class="ml-auto">
                 <!-- _ADD_NEW_LINK_ -->

+ 1 - 1
resources/views/pro/my_clients_SINGLE/SUB_ally_updates.blade.php

@@ -3,7 +3,7 @@
 
     <div class="mr-3 pb-3">
 
-        <h4 class='my-3'>
+        <h4 class='my-3 d-flex'>
             <div>Ally Updates</div>
             <div class="ml-auto">
                 <!-- _ADD_NEW_LINK_ -->

+ 1 - 1
resources/views/pro/my_clients_SINGLE/SUB_bills.blade.php

@@ -3,7 +3,7 @@
 
     <div class="mr-3 pb-3">
 
-        <h4 class='my-3'>
+        <h4 class='my-3 d-flex'>
             <div>Bills</div>
             <div class="ml-auto">
                 <!-- _ADD_NEW_LINK_ -->

+ 1 - 1
resources/views/pro/my_clients_SINGLE/SUB_care_month_entries.blade.php

@@ -3,7 +3,7 @@
 
     <div class="mr-3 pb-3">
 
-        <h4 class='my-3'>
+        <h4 class='my-3 d-flex'>
             <div>Care Month Entries</div>
             <div class="ml-auto">
                 <!-- _ADD_NEW_LINK_ -->

+ 1 - 1
resources/views/pro/my_clients_SINGLE/SUB_care_months.blade.php

@@ -3,7 +3,7 @@
 
     <div class="mr-3 pb-3">
 
-        <h4 class='my-3'>
+        <h4 class='my-3 d-flex'>
             <div>Care Months</div>
             <div class="ml-auto">
                 <!-- _ADD_NEW_LINK_ -->

+ 1 - 1
resources/views/pro/my_clients_SINGLE/SUB_mcp_updates.blade.php

@@ -3,7 +3,7 @@
 
     <div class="mr-3 pb-3">
 
-        <h4 class='my-3'>
+        <h4 class='my-3 d-flex'>
             <div>Mcp Updates</div>
             <div class="ml-auto">
                 <!-- _ADD_NEW_LINK_ -->

+ 1 - 1
resources/views/pro/my_clients_SINGLE/SUB_notes.blade.php

@@ -3,7 +3,7 @@
 
     <div class="mr-3 pb-3">
 
-        <h4 class='my-3'>
+        <h4 class='my-3 d-flex'>
             <div>Notes</div>
             <div class="ml-auto">
                 <!-- _ADD_NEW_LINK_ -->

+ 1 - 1
resources/views/pro/my_clients_SINGLE/SUB_pro_access.blade.php

@@ -3,7 +3,7 @@
 
     <div class="mr-3 pb-3">
 
-        <h4 class='my-3'>
+        <h4 class='my-3 d-flex'>
             <div>Pro Access</div>
             <div class="ml-auto">
                 <!-- _ADD_NEW_LINK_ -->

+ 1 - 1
resources/views/pro/my_clients_SINGLE/SUB_related_transactions.blade.php

@@ -3,7 +3,7 @@
 
     <div class="mr-3 pb-3">
 
-        <h4 class='my-3'>
+        <h4 class='my-3 d-flex'>
             <div>Related Transactions</div>
             <div class="ml-auto">
                 <!-- _ADD_NEW_LINK_ -->

+ 1 - 1
resources/views/pro/my_teams_SINGLE/SUB_clients.blade.php

@@ -3,7 +3,7 @@
 
     <div class="mr-3 pb-3">
 
-        <h4 class='my-3'>
+        <h4 class='my-3 d-flex'>
             <div>Clients</div>
             <div class="ml-auto">
                 <!-- _ADD_NEW_LINK_ -->

+ 1 - 0
routes/generated.php

@@ -71,6 +71,7 @@ Route::get('/my_clients/view/{uid}/SUB_erx', 'my_clients_SINGLE_Controller@SUB_e
 Route::get('/my_clients/view/{uid}/SUB_mcp_updates', 'my_clients_SINGLE_Controller@SUB_mcp_updates')->name('my_clients_SINGLE-SUB_mcp_updates');
 Route::get('/my_clients/view/{uid}/SUB_ally_updates', 'my_clients_SINGLE_Controller@SUB_ally_updates')->name('my_clients_SINGLE-SUB_ally_updates');
 Route::get('/my_clients/view/{uid}/SUB_audit_log', 'my_clients_SINGLE_Controller@SUB_audit_log')->name('my_clients_SINGLE-SUB_audit_log');
+Route::get('/my_clients/view/{uid}/ACTION_notesAddNew', 'my_clients_SINGLE_Controller@ACTION_notesAddNew')->name('my_clients_SINGLE-ACTION_notesAddNew');
 
 // --- pro: notes --- //
 Route::get('/notes', 'notes_Controller@index')->name('notes-index');