Jump to content

mongoose00318

Members
  • Posts

    235
  • Joined

  • Last visited

Everything posted by mongoose00318

  1. I have some Bootstrap popovers I'm trying to use and they work but you have to over over the element twice? Here is my JS: //initiate popover $('body').on('mouseover', '.btn_change_order_status_dialog', function() { if($(this).text() !== 'Not Started') { var btn = $(this); //perform query to determine most recent order status $.ajax({ url: 'scripts/order_status.php', method: 'GET', data: {action: 'get_order_status_history_for_dept', order_id: $(this).attr('data-order-id'), dept_code: $(this).attr('data-dept-code')}, success: function(data) { btn.attr('data-content', data); } }); } $(this).popover(); }); Here is my PHP that generates the HTML for the buttons: //build change order status buttons function build_change_order_status_btns($id, $user_dept_code, $job_number, $enterprise, $status) { // define output button array $btn = []; // produce the buttons foreach ( $status as $dept => $stat ) { //check if status ID is an array holding additonal information $status_id = is_array($stat) ? $stat['status_id'] : $stat; //retrieve expected complete time if ( isset( $stat[ 'expected_complete_time' ] ) ) { $today = new DateTime( "now" ); $expected_complete_time = new DateTime( $stat[ 'expected_complete_time' ] ); $eta = $today->diff( $expected_complete_time ); $str_eta = $eta->format( '%r%d' ); if ( $expected_complete_time->format( 'd/m/Y' ) === $today->format( 'd/m/Y' ) ) { $eta = 'Today'; } else { $eta = ( $str_eta + 1 == 1 ) ? $str_eta + 1 . ' day': $str_eta + 1 . ' days'; } } else { $eta = ''; } // enabled if user dept is 1,2,3 or the current dept matches the user's dept $enabled = in_array( $user_dept_code, [ 1, 2, 3 ] ) || in_array( $dept, explode( ',', $user_dept_code ) ) ? '' : ' disabled'; // populate the dynamic values. you should actually use a template here with replaceable tags, then only produce the button that matches the current status value $buttons[ 1 ] = "<button type='button' class='btn btn-warning btn-sm btn_change_order_status_dialog rounded-0' data-order-id='$id' data-order-number='$job_number' data-order-enterprise='$enterprise' data-dept-code='$dept' data-toggle='popover' data-trigger='hover' data-html='true' title='Order Status Summary' data-content=''$enabled>ETA: $eta</button>"; $buttons[ 2 ] = "<button type='button' class='btn btn-danger btn-sm btn_change_order_status_dialog rounded-0' data-order-id='$id' data-order-number='$job_number' data-order-enterprise='$enterprise' data-dept-code='$dept' data-toggle='popover' data-trigger='hover' data-html='true' title='Order Status Summary' data-content=''$enabled>Delayed</button>"; $buttons[ 3 ] = "<button type='button' class='btn-primary btn-sm btn_change_order_status_dialog rounded-0' data-order-id='$id' data-order-number='$job_number' data-order-enterprise='$enterprise' data-dept-code='$dept' data-toggle='popover' data-trigger='hover' data-html='true' title='Order Status Summary' data-content=''$enabled>Finished</button>"; $buttons[ 0 ] = "<button type='button' class='btn btn-secondary btn-sm btn_change_order_status_dialog rounded-0' data-order-id='$id' data-order-number='$job_number' data-order-enterprise='$enterprise' data-dept-code='$dept'$enabled>Not Started</button>"; // get the button that matches the current status value for each dept $btn[ $dept ] = $buttons[ $status_id ]; } // examine the results return $btn; } Also, I've attached a video demonstrating the problem... Untitled Project.mp4
  2. Well..I figured it out...here is the solution for others that may have this issue... You need to add blank rows between the groups you want..otherwise it just sees it as one continuous group...
  3. I've tried adjusting the setOutlineLevel but it is just grouping all of the rows together as one group right now. From my understanding the setOutlineLevel is for nesting groups anyhow...not sure what is going wrong because this code works fine: for ($row = 2; $row <= 10; ++$row) { $spreadsheet->getActiveSheet() ->getRowDimension($row) ->setOutlineLevel(1) ->setVisible(true) ->setCollapsed(false); } for ($row = 12; $row <= 20; ++$row) { $spreadsheet->getActiveSheet() ->getRowDimension($row) ->setOutlineLevel(1) ->setVisible(true) ->setCollapsed(false); } I can't spot the difference between what I'm doing with: //setup row groupings foreach ( $groupings as $g ) { $end = isset($g['end'] ) ? $g['end'] : $g['start']; for ( $row = $g['start']; $row <= $end; ++$row ) { $spreadsheet->getActiveSheet() ->getRowDimension($row) ->setOutlineLevel(1) ->setVisible(true) ->setCollapsed(false); } } and the code above it...
  4. Well..I've tried this...but it isn't quite working... $worksheet = $spreadsheet->getActiveSheet(); // Get the highest row number and column letter referenced in the worksheet $highestRow = $worksheet->getHighestRow(); // e.g. 10 $highestColumn = $worksheet->getHighestColumn(); // e.g 'F' // Increment the highest column letter $highestColumn++; $job_num_chk = ''; $groupings = []; //format the inserted records for ($row = 2; $row <= $highestRow; ++$row) { //$spreadsheet->getActiveSheet()->getRowDimension($row)->setRowHeight(53); for ($col = 'A'; $col != $highestColumn; ++$col) { $spreadsheet->getActiveSheet()->getStyle($col . $row)->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_TOP); $spreadsheet->getActiveSheet()->getStyle($col . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT); if ($col == 'B') { $cur_job_num = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue(); //get current job number //check if job number is different if ( $job_num_chk !== $cur_job_num ) { /* $spreadsheet->getActiveSheet()->insertNewRowBefore($row, 1); //insert dividing row //set dividing row to black $spreadsheet->getActiveSheet()->getStyle('A'.$row.':N'.$row)->getFill() ->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID) ->getStartColor()->setARGB('000000'); */ $job_num_chk = $cur_job_num; //update job number } $row_m = $row-1; $row_a = $row+1; $above = $spreadsheet->getActiveSheet()->getCell($col . $row_m)->getValue(); $below = $spreadsheet->getActiveSheet()->getCell($col . $row_a)->getValue(); if ( $cur_job_num !== $above ) { $groupings[$cur_job_num]['start'] = $row; } elseif ( $cur_job_num !== $below ) { $groupings[$cur_job_num]['end'] = $row; } } } } //setup row groupings foreach ( $groupings as $g ) { $end = isset($g['end'] ) ? $g['end'] : $g['start']; for ( $row = $g['start']; $row <= $end; ++$row ) { $spreadsheet->getActiveSheet() ->getRowDimension($row) ->setOutlineLevel(1) ->setVisible(true) ->setCollapsed(false); } } It seems to have made two large groups: But I've looked at my array and it seems to be correct: Array ( [22005572] => Array ( [start] => 2 [end] => 3 ) [22039882] => Array ( [start] => 4 ) [23521431] => Array ( [start] => 5 [end] => 6 ) [23616901] => Array ( [start] => 7 ) [23617551] => Array ( [start] => 8 ) [23617561] => Array ( [start] => 9 ) [23617851] => Array ( [start] => 10 [end] => 14 ) [23618511] => Array ( [start] => 15 ) [23618761] => Array ( [start] => 16 ) [22016952] => Array ( [start] => 17 [end] => 18 ) [22017812] => Array ( [start] => 19 [end] => 20 ) [22023852] => Array ( [start] => 21 [end] => 25 ) [22023892] => Array ( [start] => 26 [end] => 28 ) [22027752] => Array ( [start] => 29 [end] => 30 ) [22031712] => Array ( [start] => 31 [end] => 32 ) [22032642] => Array ( [start] => 33 [end] => 34 ) [22036842] => Array ( [start] => 35 ) [22040842] => Array ( [start] => 36 ) [22961571] => Array ( [start] => 37 ) [22978751] => Array ( [start] => 38 ) [22978831] => Array ( [start] => 39 [end] => 40 ) [22992301] => Array ( [start] => 41 ) [22992321] => Array ( [start] => 42 ) [22992331] => Array ( [start] => 43 ) [23585641] => Array ( [start] => 44 ) [22010852] => Array ( [start] => 45 [end] => 46 ) [22007412] => Array ( [start] => 47 [end] => 48 ) [22031192] => Array ( [start] => 49 [end] => 54 ) [22039462] => Array ( [start] => 55 ) [22042092] => Array ( [start] => 56 ) [23584291] => Array ( [start] => 57 [end] => 58 ) [23615841] => Array ( [start] => 59 ) [23615921] => Array ( [start] => 60 ) [23616201] => Array ( [start] => 61 ) [23616221] => Array ( [start] => 62 ) [60266410] => Array ( [start] => 63 ) [29100510] => Array ( [start] => 139 [end] => 68 ) [25294050] => Array ( [start] => 69 [end] => 74 ) [25294060] => Array ( [start] => 75 [end] => 77 ) [25294070] => Array ( [start] => 78 [end] => 83 ) [25294080] => Array ( [start] => 84 [end] => 89 ) [25294680] => Array ( [start] => 90 [end] => 93 ) [25294690] => Array ( [start] => 94 [end] => 99 ) [23616371] => Array ( [start] => 100 ) [23616381] => Array ( [start] => 101 ) [23616391] => Array ( [start] => 102 ) [23616491] => Array ( [start] => 103 [end] => 104 ) [23616731] => Array ( [start] => 105 [end] => 106 ) [23616741] => Array ( [start] => 107 ) [23551851] => Array ( [start] => 108 ) [22003322] => Array ( [start] => 109 ) [22004302] => Array ( [start] => 110 [end] => 111 ) [22011072] => Array ( [start] => 112 ) [22015832] => Array ( [start] => 113 [end] => 117 ) [22024612] => Array ( [start] => 118 ) [22026012] => Array ( [start] => 119 ) [22027702] => Array ( [start] => 120 [end] => 121 ) [22028302] => Array ( [start] => 122 ) [22028382] => Array ( [start] => 123 ) [22031532] => Array ( [start] => 124 [end] => 126 ) [22973641] => Array ( [start] => 127 ) [22979331] => Array ( [start] => 128 ) [29089920] => Array ( [start] => 129 [end] => 133 ) [23587361] => Array ( [start] => 134 [end] => 136 ) [23607111] => Array ( [start] => 137 ) [23615581] => Array ( [start] => 138 ) [23616961] => Array ( [start] => 140 [end] => 141 ) [22012662] => Array ( [start] => 142 ) [22018892] => Array ( [start] => 143 [end] => 146 ) [22022802] => Array ( [start] => 147 ) [22027922] => Array ( [start] => 148 ) [22033592] => Array ( [start] => 149 ) )
  5. I'm trying to dynamically group a range of rows using PHPSpreadsheet and having a lot of trouble thinking through the logic. My code so far looks like this: $worksheet = $spreadsheet->getActiveSheet(); // Get the highest row number and column letter referenced in the worksheet $highestRow = $worksheet->getHighestRow(); // e.g. 10 $highestColumn = $worksheet->getHighestColumn(); // e.g 'F' // Increment the highest column letter $highestColumn++; $job_num_chk = ''; $grp_start_row = ''; //format the inserted records for ($row = 2; $row <= $highestRow; ++$row) { //$spreadsheet->getActiveSheet()->getRowDimension($row)->setRowHeight(53); for ($col = 'A'; $col != $highestColumn; ++$col) { $spreadsheet->getActiveSheet()->getStyle($col . $row)->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_TOP); $spreadsheet->getActiveSheet()->getStyle($col . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT); if ($col == 'B') { $cur_job_num = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue(); //get current job number //check if job number is different if ( $job_num_chk !== $cur_job_num ) { $spreadsheet->getActiveSheet()->insertNewRowBefore($row, 1); //insert dividing row //set dividing row to black $spreadsheet->getActiveSheet()->getStyle('A'.$row.':N'.$row)->getFill() ->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID) ->getStartColor()->setARGB('000000'); $job_num_chk = $cur_job_num; //update job number } } } } This line: $grp_start_row = ''; Is where I'm hitting a mental wall...here's what the spreadsheet looks like so far: I want to be able to group the rows 101-105 in that example like below: I need to be able to determine where the start row is and the end row is in order to use the grouping feature (https://phpspreadsheet.readthedocs.io/en/latest/topics/recipes/#groupoutline-a-row) Thanks everyone.
  6. Okay cool...I have an Alias working...I think I was doing something with virtual hosts...maybe I got confused about what was what... Now, I need to get some kind of Apache log analyzer for usage statistics. I really want to use GoAccess but I can't seem to get it working (having to use Cygwin on a WAMP setup)...it looks much better than something like AWStats... Any suggestions when it comes to a log analyzer like this?
  7. @kicken Ah yes that would make sense...and yes I meant to say REMOTE_ADDR...sorry about that. So if I make an Alias of /want and the root of path to the server is http://computerName; then I would access /want via http://computerName/want?
  8. Good Morning, I have my live Apache server setup to be accessible internally over the network but I only really have one directory setup to be accessible which is accessed via the computer name (at least I think?)...so http://computerName takes you to the folder I have it pointed at. I would like to be able to setup other directories for other uses (for example AWStats) which would only be accessible to me but I've tried using Aliases and gotten nowhere...I always mess something up in the config file and have to revert back to how I had it. Also, I've tried setting up Aliases using the menu provided in WAMP and I still get nowhere. I think this is the only <Directory> config I have in it right now. <Directory /> AllowOverride none Require all granted </Directory> What do I need to do to be more specific about directories and allowing access to them? One other question, I log the IP of the users when they login, and when users are using VPN obviously their network IP is different. The VPN software has two IPs, it's main one and the one it issues to it's clients. I when I grab it using $_SERVER['SERVER_ADDR'] in PHP I always get the main VPN IP...is there a way of getting the one the VPN issues to the client? I only ask so I can tell Apache my internal IP when on the network and my IP using the VPN so I had access AWStats remotely as well...other than having to RDP into the server...
  9. @Barand @requinix Awesome. I'll give it a try. Thank you!
  10. Whew..okay trying to make sense of it. Just looked at the MySQL ref. manual on VALUES..as you suggested. That is interesting...but FIND_IN_SET only takes 1 needle to look for in the haystack, right? So how would I iterate over a list of values within the SQL statement itself? Hopefully I asked all that right.
  11. @requinix 😕 I thought you may say that...I was thinking the same thing. Is there a temporary way to accomplish this until I can change the db structure as you said? There are other parts of the application I'll have to change to match that.
  12. Okay I thought this was working pretty well but upon modifying the data in the DB a bit to put it through it's paces I ran into some issues. I get this warning in MySQL now "Warning: #1292 Truncated incorrect DOUBLE value: '8,11'" and also the dataset it returns isn't what is expected so I am doing something wrong lol. I'm still learning to make my SQL more complex 😕 $depts_to_check = [1,2,3,5,6,7,8,10,11,12,13]; $str_depts_to_check = implode(',', $depts_to_check); $query = " SELECT DISTINCT l.user_id, l.name, (SELECT COUNT(*) FROM chat_to_users WHERE to_user_id = l.user_id AND status = 0) AS total_unread FROM login l LEFT JOIN chat_to_users ctu INNER JOIN chat_message cm ON ctu.message_id = cm.chat_message_id ON l.user_id = ctu.to_user_id AND ctu.status = 0 WHERE l.dept_code IN (". $str_depts_to_check .") AND (SELECT COUNT(*) FROM chat_to_users WHERE to_user_id = l.user_id AND status = 0) > 0 AND cm.timestamp < DATE_SUB(NOW(), INTERVAL 24 HOUR) ORDER BY total_unread DESC "; $statement = $pdo->prepare($query); $statement->execute(); $results = $statement->fetchAll(); Here's the table structure of the 3 tables. CREATE TABLE `chat_message` ( `chat_message_id` int(11) NOT NULL AUTO_INCREMENT, `order_id` int(11) DEFAULT NULL, `chat_message` text NOT NULL, `timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'time message was sent', PRIMARY KEY (`chat_message_id`) ) ENGINE=InnoDB AUTO_INCREMENT=483 DEFAULT CHARSET=latin1 CREATE TABLE `chat_to_users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `message_id` int(11) NOT NULL, `order_id` int(11) DEFAULT NULL, `to_user_id` int(11) NOT NULL DEFAULT 0, `from_user_id` int(11) NOT NULL, `read_timestamp` timestamp NULL DEFAULT NULL COMMENT 'time user read message', `status` int(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=924 DEFAULT CHARSET=latin1 CREATE TABLE `login` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `dept_code` varchar(255) NOT NULL, `username` varchar(255) NOT NULL, `name` varchar(100) NOT NULL, `email` varchar(100) NOT NULL, `password` varchar(255) NOT NULL, `password_force_reset` tinyint(1) NOT NULL, PRIMARY KEY (`user_id`), UNIQUE KEY `username` (`username`) ) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=latin1 Also, I know where that warning originated from: That column (dept_code) in the login table can sometimes have a csv representation of the depts the user can belong to. Most users only have one dept_code but there are a few exceptions that have it like that. I'm not sure if I can work the query to work under this scenario?
  13. @Barand Sorry I haven't been back to this task yet but I will be back to it hopefully next week sometime and I will provide an update then.
  14. @Barand Hmm weird..it's doing something. But when I dump the $names array it only has 76 values. It should have over 115,000? Array ( [0] => ('(1)') [1] => ('1 ART CHECK LIST.CH201192') [2] => ('AS180551') [3] => ('Art (jacksonville-dc) (Z) - Shortcut (2)') [4] => ('Art (jacksonville-dc) (Z) - Shortcut (3)') [5] => ('Art (jacksonville-dc) (Z) - Shortcut') [6] => ('As173218') [7] => ('BK1144SF_LDQs Model (1)') [8] => ('CIT00028') [9] => ('CP061036_6248_NI') [10] => ('CP064096_6948SP1_SBLED') [11] => ('CT174631.E') [12] => ('CT2065FM_2LD') [13] => ('Co0771939') [14] => ('Customer Status System') [15] => ('Di202434') [16] => ('EN3038SF_Qs') [17] => ('Ex135513') [18] => ('Ex181015') [19] => ('Ex183450') [20] => ('FMD6SLR-80000_Rev_B') [21] => ('FileHandler') [22] => ('GR176558') [23] => ('HiFashion') [24] => ('MA9018CL_BKT') [25] => ('MFG (jacksonville-dc) (W) - Shortcut (3)') [26] => ('MFG (jacksonville-dc) (W) - Shortcut') [27] => ('MFG (jacksonville-dc) (Y) - Shortcut') [28] => ('MV-14 4-Product Pricer') [29] => ('M_TB1110CS_0IDMB') [30] => ('OR1618CP_FXGEHWSP') [31] => ('OR163231.E') [32] => ('PS151090.E') [33] => ('Plantation Market-MaryvilleTN') [34] => ('Ps185117') [35] => ('RVI_E Order Form - Dispenser ..') [36] => ('SFederal He18021413451') [37] => ('SG0068CP_ID3w211EMCSP_SBLED') [38] => ('SG0068RF_2L2VSP') [39] => ('SG0107RF_3w411EX_typA') [40] => ('SG133474_e') [41] => ('SG160531_e') [42] => ('SG167928_e') [43] => ('SG200030_e') [44] => ('SG2055TP_3w111SP') [45] => ('SG2056TP_3w211SP_SBLED Model (1)') [46] => ('SG2077FM_3w211SP_TYP_A') [47] => ('SG2310RF_1LDSF') [48] => ('SG3015TP_TX_SBLED') [49] => ('SH002119') [50] => ('SH103201 - Shortcut') [51] => ('SH141792') [52] => ('SHELL 609 ALLISON BONNET DR BESSEMER AL 85125') [53] => ('SPECIALT') [54] => ('Sd201942_DIE') [55] => ('Shortcut to Art & Engineering Request.mdb') [56] => ('Shortcut to Enterprise') [57] => ('Specialty Contracting Agreement - Rosedale Hwy') [58] => ('Synergy Survey Calculator - Eleventh Draft2') [59] => ('Thumbs') [60] => ('XX174610XX') [61] => ('Xx161880.E') [62] => ('Xx163854') [63] => ('Xx185178.DP') [64] => ('Xx4024NI_0IDGM') [65] => ('ci164947') [66] => ('ci167010') [67] => ('ck145891_E') [68] => ('export_1') [69] => ('mfg (Jacksonville-dc) (V) - Shortcut (2)') [70] => ('mfg (Jacksonville-dc) (V) - Shortcut (3)') [71] => ('mfg (Jacksonville-dc) (V) - Shortcut (4)') [72] => ('mfg (Jacksonville-dc) (V) - Shortcut (5)') [73] => ('mfg (Jacksonville-dc) (V) - Shortcut') [74] => ('mfg (Jacksonville-dc) (W) - Shortcut (2)') [75] => ('su2410tp') [76] => ('test') )
  15. I get this error: Fatal error: Uncaught Error: Call to a member function exec() on string in All I did was change the glob('files/*.*'); to the correct path.
  16. Here is sample data from 'drawings_pef_files" Sample data from 'production_data' Table structure -- -- Table structure for table `production_data` -- DROP TABLE IF EXISTS `production_data`; CREATE TABLE IF NOT EXISTS `production_data` ( `id` int(11) NOT NULL AUTO_INCREMENT, `job_number` int(8) NOT NULL, `enterprise` tinytext NOT NULL, `part_number` text NOT NULL, `description` text NOT NULL, `psm` tinytext NOT NULL, `qty` int(11) NOT NULL, `line_item` varchar(11) NOT NULL, `as400_ship_date` date DEFAULT NULL, `hold_reason` text NOT NULL DEFAULT '0', `hold_date` date DEFAULT NULL, `insert_time` datetime NOT NULL COMMENT 'time order was inserted or last updated', PRIMARY KEY (`id`), KEY `job_line` (`job_number`,`line_item`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; COMMIT; In the description field often times there is no DWG: prefixing the drawing number.
  17. Okay so here my code...it takes like 20 minutes to finish executing though. It would be great if I could make it faster. <?php //start timer $rustart = getrusage(); //allow more memory and execution time for script ini_set('memory_limit', '4096M'); ini_set('max_execution_time', '60000'); //include dbconfig include('scripts/dbconfig.php'); //run functions in sequence delete_drawings(); get_drawing_list($pdo); cleanup_drawing_list($pdo); get_drawings($pdo); function get_drawing_list($pdo) { $path = '\\\directoryTo\PDF_Files'; $dirs = array(); // directory handle $dir = dir($path); $query = "TRUNCATE TABLE drawings_pdf_files"; $statement = $pdo->prepare($query); $statement->execute(); while (false !== ($entry = $dir->read())) { if ($entry != '.' && $entry != '..') { if (is_dir($path . '/' .$entry)) { $query = "INSERT INTO drawings_pdf_files(fileName) VALUES(?)"; $statement = $pdo->prepare($query); $statement->execute([ $entry, ]); } } } } function cleanup_drawing_list($pdo) { $query = "SELECT * FROM drawings_pdf_files"; $statement = $pdo->prepare($query); $statement->execute(); $drawings = $statement->fetchAll(); $query = "SELECT description FROM production_data"; $statement = $pdo->prepare($query); $statement->execute(); $descriptions = $statement->fetchAll(); foreach ($drawings as $drw) { //count matches $count = 0; //compare for a match foreach ($descriptions as $desc) { if (strpos($desc['description'], $drw['fileName'])) { $count++; } } //remove the record if it has no matches if ( $count == 0 ) { $query = "DELETE FROM drawings_pdf_files WHERE id = :id"; $statement = $pdo->prepare($query); $statement->execute([ 'id' => $drw['id'], ]); } } } function get_drawings($pdo) { $query = "SELECT * FROM drawings_pdf_files"; $statement = $pdo->prepare($query); $statement->execute(); $drawings = $statement->fetchAll(); foreach($drawings as $drw) { $dir_pdf = "\\\directoryTo\PDF_Files\\"; $dir_art = $drw['fileName']; $dest_pdf = "drawings/"; //create new directory for the files mkdir($dest_pdf.$dir_art); //copy each file in that folder $list_files = array_diff(scandir($dir_pdf.$dir_art), array('..', '.')); foreach($list_files as $f) { copy( $dir_pdf . $drw['fileName'] . '\\' . $f, $dest_pdf . $drw['fileName'] . '/' . $f); } } } function delete_drawings() { $dir = "drawings/"; $di = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS); $ri = new RecursiveIteratorIterator($di, RecursiveIteratorIterator::CHILD_FIRST); foreach ( $ri as $file ) { $file->isDir() ? rmdir($file) : unlink($file); } return true; } //output usage statistics //$ru = getrusage(); //echo "This process used " . rutime($ru, $rustart, "utime") . " ms for its computations\nIt spent " . rutime($ru, $rustart, "stime") . " ms in system calls\n"; ?> The way that the drawing gets put into the description varies: CONOCO 1'10x8 VC DF TP SGN||PRINCIPAL ILLUMINATION||ENG: CO3028TP_0VPR||DWG: CO200428||TO BE: DYED DIESEL (SPEC)|| So I can't look for "DWG:" Sometimes they don't put anything in the description telling you its the drawing. People just figure it out from experience. So what I've done is pull in all of the files from the drawing folder, put it into a table, then compare each drawing with each description, remove any drawings that dont have matches, and then copy the drawing files that do have matches. @BarandWhat do you think?
  18. @Barand Yes! I'd love to do that...but...sadly when it comes to the data entry side there are no standards that are followed. I'm always having to do things backwards and goofy due to how data is stored. I've got a solution I'm working on which I'd like to hear your feedback on...just need some time to finish it. Probably will have it finished some time tomorrow. I actually got by using the strpos and str_replace functions...I look forward to your feedback. When I update I'll provide some more details as to the goofy problems I've had to work around to accomplish this (from bad data to network issues)
  19. I am trying to wrap a string with an anchor tag if it finds a match with a block of text. Here is an example text block: CONOCO 1'10x8 VC DF TP SGN||PRINCIPAL ILLUMINATION||ENG: CO3028TP_0VPR||DWG: CO200428||TO BE: DYED DIESEL (SPEC)|| The string I would want to wrap with a link would be "CO200428". The next problem is the drawings (what I'm searching the text for) has over 115,000 possibilities. The text blocks to search are over 1300. I have the drawing names stored in a simple mysql table...but doing a foreach takes forever...I imagine it will take even longer when looking in the text blocks... Is there a way to easily to do the anchor wrap? I don't know regex very well...
  20. Shipping is the last department a product goes through. If orders show as shipped (like row 4678 above) I don't want them to be included in the results from the query
  21. No it's relevant. The dept_code of 13 represents the shipping dept. So here is an example: Order 1794 had two status updates on 6/8/2020. The first one with a status_id of 1 means it was started. The next submission @ 07:22:50 with a status_id of 3 means the order has shipped. So, since that record (TBL: production_status; id: 4678; status_id: 3) exists, I'm unconcerned with any of the other records for that order. In this case record 4677. Does that make sense?
  22. Okay, it's working with it like this: SELECT pd.*, ps.* FROM production_data AS pd JOIN production_status AS ps ON ps.order_id = pd.id LEFT JOIN production_status AS chk ON chk.id = ps.id AND chk.dept_code = 13 AND chk.status_id = 3 WHERE chk.id IS NULL But, I've realized some other problems. For example, the field status_id has 4 possible values: 0 - Not started 1 - In progress 2 - Delayed 3 - Finished So I'm getting records back with status_ids of 0, 1, & 2...which makes sense to me now. I guess I didn't think through the exclusion criteria thoroughly enough...if the order has a status_id of 3 I don't want it to return any other records from the production_status table. I hope I've provided enough data for that to be helpful. Nonetheless, the query is now working and I think I understand what it is doing...mostly.
  23. I need it to give the exact opposite results of what this does: SELECT pd.*, ps.* FROM production_data AS pd JOIN production_status AS ps ON ps.order_id = pd.id AND ps.dept_code = 13 AND ps.status_id = 3 I've been tinkering with the 2nd JOIN but I just keep getting the same results...impossible where and dept_codes being returned which shouldn't be.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.