|
151 | 151 | $lastrecord=GETPOST('lastrecord', 'int'); |
152 | 152 | $search_instance_name=GETPOST('search_instance_name', 'alphanohtml'); |
153 | 153 | $search_customer_name=GETPOST('search_customer_name', 'alphanohtml'); |
| 154 | +$search_module_name=GETPOST('search_module_name', 'alphanohtml'); |
154 | 155 | $reasonundeploy=GETPOST('reasonundeploy', 'alpha'); |
155 | 156 | $commentundeploy=GETPOST('commentundeploy', 'alpha'); |
156 | 157 |
|
|
186 | 187 | if (GETPOSTISSET('reset')) { |
187 | 188 | $search_instance_name = ''; |
188 | 189 | $search_customer_name = ''; |
| 190 | + $search_module_name = ''; |
189 | 191 | } |
190 | 192 | $fromsocid=GETPOST('fromsocid', 'int'); |
191 | 193 |
|
|
318 | 320 | if (getDolGlobalInt('SELLYOURSAAS_ALLOW_MODULE_PROVIDER_PROGRAM') > 0) { |
319 | 321 | // TODO Read if there is some product prices in supplier tab of the thirdparty. If yes it is a module provider and we have the list of provided modules |
320 | 322 | //$mythirdpartyaccount->isamoduleprovider = array('aa', 'bbb'); |
| 323 | + $sql = "SELECT p.rowid FROM ".MAIN_DB_PREFIX."product as p"; |
| 324 | + $sql.= " JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; |
| 325 | + $sql.= " ON pfp.fk_product = p.rowid"; |
| 326 | + $sql.= " WHERE pfp.fk_soc = ".$mythirdpartyaccount->id; |
| 327 | + $resql=$db->query($sql); |
| 328 | + if ($resql) { |
| 329 | + $num_rows = $db->num_rows($resql); |
| 330 | + $i = 0; |
| 331 | + while ($i < $num_rows) { |
| 332 | + $obj = $db->fetch_object($resql); |
| 333 | + if ($obj) { |
| 334 | + $mythirdpartyaccount->isamoduleprovider[] = $obj->rowid; |
| 335 | + } |
| 336 | + $i++; |
| 337 | + } |
| 338 | + } else { |
| 339 | + dol_print_error($db); |
| 340 | + } |
321 | 341 | } |
322 | 342 |
|
323 | 343 | $nbtotalofrecords = 0; |
|
401 | 421 | } |
402 | 422 | //var_dump(array_keys($listofcontractidreseller)); |
403 | 423 |
|
| 424 | +$listofcontractidmodulesupplier = array(); |
| 425 | +// Load list of child instance for module supplier |
| 426 | +if (!empty($mythirdpartyaccount->isamoduleprovider) && in_array($mode, array('mymodulecustomerinstances', 'mymodulecustomerbilling'))) { |
| 427 | + $sql = 'SELECT DISTINCT c.rowid'; |
| 428 | + $sql.= ' FROM '.MAIN_DB_PREFIX.'contrat as c'; |
| 429 | + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'contratdet as d ON d.fk_contrat = c.rowid'; |
| 430 | + $sql.= ', '.MAIN_DB_PREFIX.'product as p'; |
| 431 | + $sql.= " WHERE d.fk_product = p.rowid"; |
| 432 | + $sql.= " AND d.fk_product IN (".(implode(",", $mythirdpartyaccount->isamoduleprovider)).")"; |
| 433 | + $sql.= " AND d.statut = 4"; |
| 434 | + |
| 435 | + if ($search_instance_name) { |
| 436 | + $sql.=natural_search(array('c.ref_customer'), $search_instance_name); |
| 437 | + } |
| 438 | + if ($search_module_name) { |
| 439 | + $sql.=natural_search(array('p.ref','p.label'), $search_module_name); |
| 440 | + } |
| 441 | + |
| 442 | + $resql=$db->query($sql); |
| 443 | + if ($resql) { |
| 444 | + $num_rows = $db->num_rows($resql); |
| 445 | + $i = 0; |
| 446 | + while ($i < $num_rows) { |
| 447 | + $obj = $db->fetch_object($resql); |
| 448 | + if ($obj) { |
| 449 | + if (empty($listofcontractidmodulesupplier[$obj->rowid])) { |
| 450 | + $contract=new Contrat($db); |
| 451 | + $contract->fetch($obj->rowid); // This load also lines |
| 452 | + $listofcontractidmodulesupplier[$obj->rowid] = $contract; |
| 453 | + } |
| 454 | + } |
| 455 | + $i++; |
| 456 | + } |
| 457 | + if (empty($lastrecord) || $lastrecord > $num_rows) { |
| 458 | + $lastrecord = $num_rows; |
| 459 | + } |
| 460 | + } else { |
| 461 | + dol_print_error($db); |
| 462 | + } |
| 463 | + |
| 464 | +} |
| 465 | + |
404 | 466 | // Define environment of payment modes |
405 | 467 | $servicestatusstripe = 0; |
406 | 468 | if (isModEnabled('stripe')) { |
|
2401 | 2463 |
|
2402 | 2464 | if (count($mythirdpartyaccount->isamoduleprovider) > 0) { |
2403 | 2465 | print ' |
2404 | | - <li class="nav-item'.($mode == 'moduleprovider' ? ' active' : '').' dropdown"> |
| 2466 | + <li class="nav-item'.(($mode == 'mymodulecustomerinstances' || $mode == 'mymodulecustomerbilling') ? ' active' : '').' dropdown"> |
2405 | 2467 | <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-suitcase"></i> '.$langs->trans("ModuleProviderArea").'</a> |
2406 | 2468 | <ul class="dropdown-menu">'; |
2407 | 2469 | // Module provider stats |
2408 | | - //print '<li><a class="dropdown-item" href="'.$_SERVER["PHP_SELF"].'?mode=mycustomerinstances"><i class="fa fa-server pictofixedwidth"></i> '.$langs->trans("MyCustomersInstances").'</a></li>'; |
| 2470 | + print '<li><a class="dropdown-item" href="'.$_SERVER["PHP_SELF"].'?mode=mymodulecustomerinstances"><i class="fa fa-server pictofixedwidth"></i> '.$langs->trans("MyModuleCustomersInstances").'</a></li>'; |
2409 | 2471 | // Divider |
2410 | | - //print '<li class="dropdown-divider"></li>'; |
| 2472 | + print '<li class="dropdown-divider"></li>'; |
2411 | 2473 | // Customers ofmy module area |
2412 | 2474 | print '<li><a class="dropdown-item" href="'.$_SERVER["PHP_SELF"].'?mode=mymodulecustomerbilling"><i class="fa fa-usd"></i> '.$langs->trans("MyModuleCustomersBilling").'</a></li>'; |
2413 | 2475 | print ' |
|
0 commit comments