Skip to content

Commit

Permalink
pequenas correções na interface de códigos de serviços #9
Browse files Browse the repository at this point in the history
  • Loading branch information
andrekutianski committed Oct 18, 2021
1 parent 0c0e66a commit 01bed86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
class Repository extends \WHMCSExpert\mtLibs\models\Repository
{

public static $tableName = 'mod_nfeio_si_productcode';
public static $fieldDeclaration = array(
public $tableName = 'mod_nfeio_si_productcode';
public $fieldDeclaration = array(
'id',
'product_id',
'code_service',
Expand All @@ -28,12 +28,12 @@ function getModelClass()

public function fieldDeclaration()
{
return self::$fieldDeclaration;
return $this->fieldDeclaration;
}

public function tableName()
{
return self::$tableName;
return $this->tableName;
}

/**
Expand All @@ -44,9 +44,9 @@ public function tableName()
public function dataTable()
{
return Capsule::table('tblproducts')
->leftJoin(self::$tableName, 'tblproducts.id', '=', self::$tableName.'.product_id')
->leftJoin($this->tableName, 'tblproducts.id', '=', $this->tableName.'.product_id')
->orderByDesc('tblproducts.id')
->select('tblproducts.id', 'tblproducts.name', self::$tableName.'.code_service')
->select('tblproducts.id', 'tblproducts.name', $this->tableName.'.code_service')
->get()
->toArray();
}
Expand All @@ -58,7 +58,7 @@ public function save($data)
}*/

try {
return Capsule::table(self::$tableName)->updateOrInsert(
return Capsule::table($this->tableName)->updateOrInsert(
[ 'product_id' => $data['product_id'] ],
[
'code_service' => $data['service_code'],
Expand All @@ -73,7 +73,7 @@ public function save($data)
public function delete($data)
{
try {
return Capsule::table(self::$tableName)
return Capsule::table($this->tableName)
->where('product_id', '=', $data['product_id'])
->delete();
} catch (\Exception $exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
<form action="{$modulelink}&action={$formAction}" method="post">
<td>{$produto->id}</td>
<td>{$produto->name}</td>
<td><input class="form-control" type="text" name="service_code" value="{$produto->code_service}"></td>
<td><input class="form-control" type="text" name="service_code" required value="{$produto->code_service}"></td>
<td>
<input type="hidden" name="product_id" value="{$produto->id}">
<input type="hidden" name="product_name" value="{$produto->name}">
<button type="submit" class="btn btn-success btn-sm" name="btnSave" value="true">Salvar Código</button>
{if $produto->code_service}
<button type="submit" class="btn btn-danger btn-sm" name="btnDelete" value="true">Excluir Código</button>
{/if}
</td>
</form>

Expand Down

0 comments on commit 01bed86

Please sign in to comment.