Skip to main content

Topics

This section allows you to view all Topics made by this member. Note that you can only see Topics made in areas you currently have access to.

Topics - dobsun

1
Issues / multiple data bases
Hello,
Please help!
I would like use different Mysql db with one instalation !?
so far my project is simple cash flow for different shops, it is ready installed on server, works fine for one shop only! but I have 22 shops, I don't want 22 installations, they should use different db, as they don't need to see each other... so I have 22 same structure data bases and one installation...
So i have made drop down menu in index file just before log in, in order to change  db name in config.php :
define("DB_NAME", "cashflow_1");
result is Notice: Constant DB_NAME already defined in ...
so I have that problem as once constant is defined we can't change it !

So I have that fight for few days,
I have try so far to change hole config.php, it makes some other issues,
I have try undefine, I have no full control of that server, so that php plugin is not an option,
I have try true and false statment for define...
I have try delete from config.php and put  in PDOdb.php my own variable... but I'm doing something wrong
please advice?  other ideas, that could solve that?
or Where to put my variable $db_name to make it work?

2
Questions / what a user see? what none user see?
Hello,
Before a year I create small project with PHPrad 2.7.3,  I needed only login Authentication and I was happy!
Now I decided to make my project more open  so I make some pages to be seen by guest !
In Authentication I marked pages that no require user Authentication(guest) ... it works by direct link!

the problem :
I was expecting to see menu with those pages  + login link and completely different home page!
How to create a menu for that guest? Did I miss something?
Is there an easy way or I should do menu/guest/home/etc pages my self ?

New version of phprad - is there a guest section? what to expect ? When is coming?
5
Issues / Notice: Trying to access array offset on value of type null
Hello,
I get this: Notice: Trying to access array offset on value of type null
My code is working stand alone!
  but it is not working in PHPRAD!

this is the part of the code that return the notice:
  return isset($_num0[$nmber]) ? $_num0[$nmber] : $_mod10[$nmber] ."надесет";

help, please
6
Issues / number_to_words issue
I have this code :
...
$total=4654;
   print "<b>".to_number($total,$lang="en")."</b>";
   print "<b>".number_to_words($total,$lang="en")."</b>";
...

it returns
...
Error 500
Server Error
Error Message   Class 'NumberFormatter' not found

how to make it work?
where is NumberFormatter as file ?
where to check what languages are as options $lang="en"?
7
Questions / How to call an array in add page from controller?
From few days I can't figure out the following:
I want to call array in add.php!

code:
// in page event before add:
......
if(isset($_POST['update'])){
 $fields = array("doc" => $_POST['doc'],
                          "test" => "11111111111111111111111"
);
 $this->set_flash_msg(get_lang('UPDATED! '), "success");
               return   $this->redirect("docs/add");
}
.....
//in add.php
I have try so much different options in controller and add.php as: $modeldata['test']; $data = $this->view_data; request, view_data, $data['test'], I even make my own view functions and etc... and No it didn't work... due to some reasons, it clear the array and display blank: and gives Notice: Trying to access array offset … or print_r gives blank array etc...
I call the controller to display other arrays  from DB as well, that seems to be the main issue... as that calls are bellow in page, and mayby that is what clears my $post['update'] data?

Please advice, how to call this array in add page?
<?php
// I want to call it this in add.php
echo fields['doc'];
echo fields['test'];

//but how to do it?
8
General Discussion / Page Events
I decide to start General discussion on page EVENT!
All of us are doing own projects but with similar stuff , so the idea of the post is to help each other, and after all to spent some time!
So:
My page event is related to table 'docs', event after ADD.php page in \app\views\partials\docs .
In general: Page events code is saved in  \app\Controllers\ in my case => DocsController.php
In Page design > page select -  Docs/Add >
I made for DocAddForm page /include page - false
Then I create my own customView and in customCode I just put this <?php include "add_inc_form.php"; ?>,
add_inc_form.php - this is my custom made form that should include and update in 3 tables, I just keep form link and EXPORT part from original add.php
So this is my after add event code

//$_POST['pcount'] gives number of cart items
        for ($i=0; $i<($_POST['pcount']); $i++){
            $ci=$i+1;
            $scr = 0;
            if(isset($_POST['product_scrap_'.$ci])){
            $scr = $_POST['product_scrap_'.$ci];
            }
//few calculations
            $value = ($_POST['product_price_'.$ci])*($_POST['product_qty_'.$ci]);

//array of $_post
 $table_data = array(
 "doc" => $_POST['doc'],
  "doc_id" => $_POST['doc_id'],
  "part_id" => $_POST['part_id'],
  "company_id" => $_POST['company_id'],
  "product_name" => $_POST["product_name_".$ci],
  "product_id" => $_POST["product_id_".$ci],
  "qty" => $_POST["product_qty_".$ci],
  "price" => $_POST["product_price_".$ci],
  "type" => $_POST["product_type_".$ci],
  "value" => $value,
  "scrap_id" => $scr
 
);
//insert into table sales
$db->insert("sales", $table_data);
}

//loop for update in quantity in product table
for ($up=0; $up<($_POST['pcount']); $up++){
$ups        = $up+1;
$qty        = $_POST['product_total_qty_'.$ups] - $_POST['product_qty_'.$ups];
$product_id = $_POST["product_id_".$ups];

$table_update = array(
    "quantity" => $qty
    );

    $db->where("id", $product_id);
    $bool = $db->update("product", $table_update);
}

// clear all cookie
$cc=get_cookie ('cart');
    clear_cookie ("partner");
    if (isset($cc)) {
        foreach ($cc as $name => $value) {
            clear_cookie ("cart[".$name."]");
        }
    }
 
As I'm not a pro, I will appreciated any advices on my code above?
If you have Page Events code that could be useful for other like me, please share...
If you have problems on Page Evens please share

9
Questions / how to insert in different table?
My problems with inserting and updating are not over yet!
in docs/add page, I made an afterAdd event in page Events as follow:

$table_data = array(
  "doc" => $modeldata['doc'],
    "doc_id" => $modeldata['doc_id'],
       "part_id" => $modeldata['part_id'],
    "company_id" => $modeldata['company_id']
  );
$db->insert("sales", $table_data);

it is working perfect except for $modeldata['doc_id']
Notice: Undefined index: doc_id in C:\xampp\htdocs\stock_3\app\controllers\DocsController.php on line 231
I try everything I know so far, I can't get print_r($_POST) data as it go true the controller and redirect...
What I know so far is that: 'doc_id' is the only column in 'sales' table that is not in 'docs' table
What I think is happening phprad is cutting doc_id from POST data due to some reasons ?
help please?

10
Suggestions / Ctrl+S
Ctrl+S
please make it work!
at least for editor and saving project
Other short cuts will help!
11
Questions / How to prevent overwrite BaseController.php?
I have made some correction to baseController !   Some cookies functions and they should be in here as they are valid for all!
There is no standard option to prevent publishing baseController!
If I just open the project in phprad and baseController is overwritten..

I'm tired of copy/paste and in most cases I don't see phprad touching inside at all!
And to stop phprad updating I make the BaseController  [read only ] , but that is stupid
so
How to edit BaseController as my correction will stay?
12
Questions / how to add new button next to view|edit|delete ?
how to add new button next to view|edit|delete ?
1. one way is open with editor the list.php and it is ready ...
but problem in that case is if I change the project slightly phpRad simply overwrite ...
2. so what I do in [ Name Field Properties] [01 Display] I chose custom  and put my button:
<a class="btn btn-sm btn-success has-tooltip" href="?pid=<?php echo $rec_id; ?>&qty=1">ADD </a>  
but problem in that case is it go in the export or to printer  ?

so how to do it to prevent both problems ?
it should be a way to add buttons as [add][copy][compare][etc...] 
advice?


---
ps: I have try to upload screen shot but your server is giving this:
There was a problem during the uploading of add.jpg.
The upload directory is full. Please contact an administrator about this problem.
14
Bugs / relation bug
I have made two relation in "doc" table,
first the id is related to sales table doc_id,
second partner_id to id of partner table.

due to some reason they mix in some rows,
 if you click partner link on first and second row it lead once to partner second to sales
???
15
Questions / multi insert update
Hello All,
First I have made a copy of add page for table 'docs',
then by editor  I make my custom Form, that is working and all parameters are passed true POST method,
// action="<?php print_link("docs/add?csrf_token=$csrf_token") ?>"
but it insert only in one table 'docs',
so I need to INSERT some VALUES in two more tables 'partner' , 'sales' and to UPDATE "qty" in  'product'
what/where is the right way to do it?
then I need to redirect to custom view page LAST record?

So I'm confused from that in docsControler.php ,
function add(){
if($formdata){
         $db = $this->GetModel();
         $tablename = $this->tablename;
....
I could make my own functions and do it my way, but I would like to understand the logic here and do it right way!
So advice how to make that multi-insert ?